Part Number Hot Search : 
B8272 AN1552 AD7417BR N302010 68HC08 CD4036 BSS61 BPC1002
Product Description
Full Text Search
 

To Download P89CV51RD2FA512 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  1. general description the p89cv51rb2/rc2/rd2 are three types of 80c51 microcontroller with respectively 16 kb/32 kb/64 kb ?ash and 1 kb of data ram. these devices are designed to be drop-in and software-compatible replacements for the popular p89c51rb2/rc2/rd2 devices. both the in-system programming (isp) and in-application programming (iap) boot codes are upward compatible. additional features of the p89cv51rb2/rc2/rd2 devices compared to the p89c51rb2/rc2/rd2 are the inclusion of an spi interface, larger ram size, and the ability to erase code memory in 128-b page blocks. the iap capability combined with the 128-b page size allows for ef?cient use of the code memory for non-volatile data storage. 2. features 2.1 principal features n supports 12-clock (default) or 6-clock mode selection via isp or parallel programmer n 6-clock/12-clock mode programmable on-the-?y by an sfr bit n peripherals (pca, timers, uart) may use either 6-clock or 12-clock mode while the cpu is in 6-clock mode n 128-b page erase for ef?cient use of code memory as non-volatile data storage n 0 mhz to 40 mhz operating frequency in 12 mode, 20 mhz in 6 mode n 16/32/64 kb of on-chip ?ash user-code memory with isp and iap n 1 kb ram n spi (serial peripheral interface) and enhanced uart n pca (programmable counter array) with pwm and capture/compare functions n three 16-bit timers/counters 2.2 additional features n four 8-bit i/o ports n watchdog timer (wdt) n 30 ms page erase, 150 ms block erase n plcc44 and tqfp44 packages n ten interrupt sources with four priority levels n second dptr register n low emi mode (ale inhibit) p89cv51rb2/rc2/rd2 8-bit 80c51 5 v low power 64 kb ?ash microcontroller with 1 kb ram, spi, 6-clock cpu with 6/12-clock peripherals rev. 03 25 august 2009 product data sheet
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 2 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi n power-down mode with external interrupt wake-up n idle mode 2.3 comparison to p89c51rb2/rc2/rd2 devices n spi: the p89cv51rb2/rc2/rd2 devices have an spi interface that was not present on the p89c51rb2/rc2/rd2 devices. n smaller block size: the page size decreased from 4 kb to 128 b. these smaller pages can be erased and reprogrammed using iap function calls, which makes practical use of code memory for non-volatile data storage. a page is erased in 30 ms or less. iap and isp code both support 128-b page operations. the iap and isp code uses multiple page-erase operations to emulate the erasing of larger block sizes (8 kb and 16 kb) to maintain ?rmware compatibility. n status bit replaces status byte: automatic entry into isp mode following a reset is now controlled by one status bit. its operation is almost identical to that used by the previous devices, which was based on the zero/non-zero value of the status byte. n faster block erase: the erase time for the entire user-code memory of the p89cv51rb2/rc2/rd2 devices is 150 ms, which is a signi?cant improvement. n larger ram size: ram size increased from 512 b to 1 kb. 3. ordering information 3.1 ordering options table 1. ordering information type number package name description version p89cv51rb2fa plcc44 plastic leaded chip carrier; 44 leads sot187-2 p89cv51rb2fbc tqfp44 plastic thin quad ?at package; 44 leads; body 10 10 1.0 mm sot376-1 p89cv51rc2fa plcc44 plastic leaded chip carrier; 44 leads sot187-2 p89cv51rc2fbc tqfp44 plastic thin quad ?at package; 44 leads; body 10 10 1.0 mm sot376-1 p89cv51rd2fa plcc44 plastic leaded chip carrier; 44 leads sot187-2 p89cv51rd2fbc tqfp44 plastic thin quad ?at package; 44 leads; body 10 10 1.0 mm sot376-1 table 2. ordering options type number flash memory ram temperature range frequency p89cv51rb2fa 16 kb 1 kb - 40 c to +85 c 0 mhz to 40 mhz p89cv51rb2fbc p89cv51rc2fa 32 kb 1 kb p89cv51rc2fbc p89cv51rd2fa 64 kb 1 kb p89cv51rd2fbc
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 3 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 4. block diagram fig 1. block diagram high performance 80c51 cpu 16 kb/32 kb/64 kb code flash 1 kb data ram port 1 port 0 oscillator internal bus crystal or resonator 002aac960 uart pca programmable counter array port 2 timer 2 timer 0 timer 1 spi xtal1 xtal2 watchdog timer port 3 p3[7:0] p2[7:0] p1[7:0] p0[7:0] txd rxd t0 spiclk mosi miso ss t1 t2 t2ex cex[4:0] p89cv51rb2/rc2/rd2
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 4 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 5. pinning information 5.1 pinning fig 2. plcc44 pin con?guration p89cv51rb2/rc2/rd2 p1[5]/cex2/mosi p0[4]/ad4 p1[6]/cex3/miso p0[5]/ad5 p1[7]/cex4/spiclk p0[6]/ad6 rst p0[7]/ad7 p3[0]/rxd n.c. p3[1]/txd p2[7]/a15 p3[4]/t0 p2[6]/a14 p3[5]/t1 p2[5]/a13 p1[4]/cex1/ss p1[3]/cex0 xtal2 p1[2]/eci xtal1 p1[1]/t2ex v ss p1[0]/t2 n.c. n.c. p2[0]/a8 v dd p2[1]/a9 p0[0]/ad0 p2[2]/a10 p0[1]/ad1 p2[3]/a11 p0[2]/ad2 p2[4]/a12 p0[3]/ad3 002aac962 7 8 9 10 11 12 13 14 15 16 17 39 38 37 36 35 34 33 32 31 30 29 18 19 20 21 22 23 24 25 26 27 28 6 5 4 3 2 1 44 43 42 41 40 ea ale psen p3[6]/wr p3[7]/rd p3[3]/int1 p3[2]/int0 n.c.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 5 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 5.2 pin description fig 3. tqfp44 pin con?guration p89cv51rb2/rc2/rd2 p1[5]/cex2/mosi p0[4]/ad4 p1[6]/cex3/miso p0[5]/ad5 p1[7]/cex4/spiclk p0[6]/ad6 rst p0[7]/ad7 p3[0]/rxd n.c. p3[1]/txd p2[7]/a15 p3[4]/t0 p2[6]/a14 p3[5]/t1 p2[5]/a13 p1[4]/cex1/ss p1[3]/cex0 xtal2 p1[2]/eci xtal1 p1[1]/t2ex v ss p1[0]/t2 n.c. n.c. p2[0]/a8 v dd p2[1]/a9 p0[0]/ad0 p2[2]/a10 p0[1]/ad1 p2[3]/a11 p0[2]/ad2 p2[4]/a12 p0[3]/ad3 002aac961 ea ale psen p3[6]/wr p3[7]/rd p3[3]/int1 p3[2]/int0 n.c. 1 2 3 4 5 6 7 8 9 10 11 33 32 31 30 29 28 27 26 25 24 23 12 13 14 15 16 17 18 19 20 21 22 44 43 42 41 40 39 38 37 36 35 34 table 3. p89cv51rb2/rc2/rd2 pin description symbol pin type description plcc44 tqfp44 p0[0] to p0[7] i/o port 0 : port 0 is an 8-bit open-drain bidirectional i/o port. port 0 pins that have 1s written to them ?oat, and in this state can be used as high-impedance inputs. port 0 is also the multiplexed low-order address and data bus during accesses to external code and data memory. in this application, it uses strong internal pull-ups when transitioning to 1s. external pull-ups are required when used as a general purpose i/o port. p0[0]/ad0 43 37 i/o p0[0] port 0 bit 0. i/o ad0 address/data bit 0. p0[1]/ad1 42 36 i/o p0[1] port 0 bit 1. i/o ad1 address/data bit 1. p0[2]/ad2 41 35 i/o p0[2] port 0 bit 2. i/o ad2 address/data bit 2. p0[3]/ad3 40 34 i/o p0[3] port 0 bit 3. i/o ad3 address/data bit 3. p0[4]/ad4 39 33 i/o p0[4] port 0 bit 4. i/o ad4 address/data bit 4. p0[5]/ad5 38 32 i/o p0[5] port 0 bit 5. i/o ad5 address/data bit 5.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 6 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi p0[6]/ad6 37 31 i/o p0[6] port 0 bit 6. i/o ad6 address/data bit 6. p0[7]/ad7 36 30 i/o p0[7] port 0 bit 7. i/o ad7 address/data bit 7. p1[0] to p1[7] i/o with internal pull-up port 1 : port 1 is an 8-bit bidirectional i/o port with internal pull-ups. the port 1 pins are pulled high by the internal pull-ups when 1s are written to them and can be used as inputs in this state. as inputs, port 1 pins that are externally pulled low will source current (i il ) because of the internal pull-ups. p1[5], p1[6], p1[7] have high current drive of 16 ma. p1[0]/t2 2 40 i/o p1[0] port 1 bit 0. i/o t2 external count input to timer/counter 2 or clock-out from timer/counter 2. p1[1]/t2ex 3 41 i/o p1[1] port 1 bit 1. i t2ex : timer/counter 2 capture/reload trigger and direction control. p1[2]/eci 4 42 i/o p1[2] port 1 bit 2. i eci external clock input. this signal is the external clock input for the pca. p1[3]/cex0 5 43 i/o p1[3] port 1 bit 3. i/o cex0 capture/compare external i/o for pca module 0. each capture/compare module connects to a port 1 pin for external i/o. when not used by the pca, this pin can handle standard i/o. p1[4]/cex1/ ss 6 44 i/o p1[4] port 1 bit 4. i/o cex1 capture/compare external i/o for pca module 1. i ss slave select input for spi. p1[5]/cex2/ mosi 7 1 i/o p1[5] port 1 bit 5. i/o cex2 capture/compare external i/o for pca module 2. i/o mosi master output/slave input for spi. p1[6]/cex3/ miso 8 2 i/o p1[6] port 1 bit 6. i/o cex3 capture/compare external i/o for pca module 3. i/o miso master input/slave output for spi. p1[7]/cex4/ spiclk 9 3 i/o p1[7] port 1 bit 7. i/o cex4 capture/compare external i/o for pca module 4. i/o spiclk serial clock input/output for spi. p2[0] to p2[7] i/o with internal pull-up port 2 : port 2 is an 8-bit bidirectional i/o port with internal pull-ups. port 2 pins are pulled high by the internal pull-ups when 1s are written to them and can be used as inputs in this state. as inputs, port 2 pins that are externally pulled low will source current (i il ) because of the internal pull-ups. port 2 sends the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit address (movx @dptr). in this application, it uses strong internal pull-ups when transitioning to 1s. p2[0]/a8 24 18 i/o p2[0] port 2 bit 0. o a8 address bit 8. table 3. p89cv51rb2/rc2/rd2 pin description continued symbol pin type description plcc44 tqfp44
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 7 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi p2[1]/a9 25 19 i/o p2[1] port 2 bit 1. o a9 address bit 9. p2[2]/a10 26 20 i/o p2[2] port 2 bit 2. o a10 address bit 10. p2[3]/a11 27 21 i/o p2[3] port 2 bit 3. o a11 address bit 11. p2[4]/a12 28 22 i/o p2[4] port 2 bit 4. o a12 address bit 12. p2[5]/a13 29 23 i/o p2[5] port 2 bit 5. o a13 address bit 13. p2[6]/a14 30 24 i/o p2[6] port 2 bit 6. o a14 address bit 14. p2[7]/a15 31 25 i/o p2[7] port 2 bit 7. o a15 address bit 15. p3[0] to p3[7] i/o with internal pull-up port 3 : port 3 is an 8-bit bidirectional i/o port with internal pull-ups. port 3 pins are pulled high by the internal pull-ups when 1s are written to them and can be used as inputs in this state. as inputs, port 3 pins that are externally pulled low will source current (i il ) because of the internal pull-ups. p3[0]/rxd 11 5 i/o p3[0] port 3 bit 0. i rxd serial input port. p3[1]/txd 13 7 i/o p3[1] port 3 bit 1. o txd serial output port. p3[2]/ int0 14 8 i/o p3[2] port 3 bit 2. i int0 external interrupt 0 input. p3[3]/ int1 15 9 i/o p3[3] port 3 bit 3. i int1 external interrupt 1 input. p3[4]/t0 16 10 i/o p3[4] port 3 bit 4. i t0 external count input to timer/counter 0. p3[5]/t1 17 11 i/o p3[5] port 3 bit 5. i t1 external count input to timer/counter 1. p3[6]/ wr 18 12 i/o p3[6] port 3 bit 6. o wr external data memory write strobe. p3[7]/ rd 19 13 i/o p3[7] port 3 bit 7. o rd external data memory read strobe. psen 32 26 o program store enable : psen is the read strobe for external program memory. when the device is executing from internal program memory, psen is inactive (high). when the device is executing code from external program memory, psen is activated twice each machine cycle, except that two psen activations are skipped during each access to external data memory. table 3. p89cv51rb2/rc2/rd2 pin description continued symbol pin type description plcc44 tqfp44
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 8 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi [1] ale loading issue: when ale pin experiences higher loading (> 30 pf) during the reset, the microcontroller may accidentally enter into modes other than normal working mode. the solution is to add a pull-up resistor from 3 k w to 50 k w between e.g., ale pin and v dd . [2] for 6-clock mode, ale is emitted at 1 3 of crystal frequency. rst 10 4 i reset : while the oscillator is running, a high logic state on this pin for two machine cycles will reset the device. ea 35 29 i external access enable : ea must be connected to v ss in order to enable the device to fetch code from the external program memory. ea must be strapped to v dd for internal program execution. ale 33 27 i/o address latch enable : ale is the output signal for latching the low byte of the address during an access to external memory. normally the ale [1] is emitted at a constant rate of 1 6 the crystal frequency [2] and can be used for external timing and clocking. one ale pulse is skipped during each access to external data memory. however, if bit ao is set to 1, ale is disabled. xtal1 21 15 i crystal 1 : input to the inverting oscillator ampli?er and input to the internal clock generator circuits. xtal2 20 14 o crystal 2 : output from the inverting oscillator ampli?er. v dd 44 38 supply power supply v ss 22 16 supply ground table 3. p89cv51rb2/rc2/rd2 pin description continued symbol pin type description plcc44 tqfp44
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 9 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6. functional description 6.1 special function registers remark: sfr accesses are restricted in the following ways: ? do not attempt to access any sfr locations that are unde?ned. ? access to de?ned sfr locations must be strictly for the functions of the sfrs. ? sfr bits labeled -, 0 or 1 can only be written and read as follows: C - unless otherwise speci?ed, must be written with 0, but can return any value when read (even if it was written with 0). it is a reserved bit and may be used in future derivatives. C 0 must be written with 0, and will return a 0 when read. C 1 must be written with 1, and will return a 1 when read.
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 10 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi table 4. special function registers * indicates sfrs that are bit addressable. name description sfr address bit functions and addresses [1] msb lsb bit address e7 e6 e5 e4 e3 e2 e1 e0 acc* accumulator e0h -------- auxr auxiliary function register 8eh ------ extram ao auxr1 auxiliary function register 1 a2h - - enboot - gf2 0 - dps bit address f7 f6 f5 f4 f3 f2 f1 f0 b* b register f0h -------- ccap0h module 0 capture high fah -------- ccap1h module 1 capture high fbh -------- ccap2h module 2 capture high fch -------- ccap3h module 3 capture high fdh -------- ccap4h module 4 capture high feh -------- ccap0l module 0 capture low eah -------- ccap1l module 1 capture low ebh -------- ccap2l module 2 capture low ech -------- ccap3l module 3 capture low edh -------- ccap4l module 4 capture low eeh -------- ccapm0 module 0 mode dah - ecom_0 capp_0 capn_0 mat_0 tog_0 pwm_0 eccf_0 ccapm1 module 1 mode dbh - ecom_1 capp_1 capn_1 mat_1 tog_1 pwm_1 eccf_1 ccapm2 module 2 mode dch - ecom_2 capp_2 capn_2 mat_2 tog_2 pwm_2 eccf_2 ccapm3 module 3 mode ddh - ecom_3 capp_3 capn_3 mat_3 tog_3 pwm_3 eccf_3 ccapm4 module 4 mode deh - ecom_4 capp_4 capn_4 mat_4 tog_4 pwm_4 eccf_4 bit address df de dd dc db da d9 d8 ccon* pca counter control d8h cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 ch pca counter high f9h -------- cl pca counter low e9h -------- cmod pca counter mode d9h cidl wdte - - - cps1 cps0 ecf ckcon clock control 8fh spix2 wdx2 pcax2 six2 t2x2 t1x2 t0x2 x2
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 11 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi dptr data pointer (2 b) dph data pointer high 83h -------- dpl data pointer low 82h -------- bit address af ae ad ac ab aa a9 a8 ie* interrupt enable a8h ea ec et2 es et1 ex1 et0 ex0 bit address bf be bd bc bb ba b9 b8 ip* interrupt priority low b8h - ppc pt2 ps pt1 px1 pt0 px0 iph interrupt priority high b7h - ppch pt2h psh pt1h px1h pt0h px0h bit address 87 86 85 84 83 82 81 80 p0* port 0 80h ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 bit address 97 96 95 94 93 92 91 90 p1* port 1 90h cex4/ spiclk cex3/ miso cex2/ mosi cex1/ ss cex0 eci t2ex t2 bit address a7 a6 a5 a4 a3 a2 a1 a0 p2* port 2 a0h a15 a14 a13 a12 a11 a10 a9 a8 bit address b7 b6 b5 b4 b3 b2 b1 b0 p3* port 3 b0h rd wr t1 t0 int1 int0 txd rxd pcon power control 87h smod1 smod0 - pof gf1 gf0 pd idl bit address d7 d6 d5 d4 d3 d2 d1 d0 psw* program status word d0h cy ac f0 rs1 rs0 ov f1 p rcap2h timer 2 capture high cbh -------- rcap2l timer 2 capture low cah -------- bit address 9f 9e 9d 9c 9b 9a 99 98 scon* serial port control 98h sm0/fe sm1 sm2 ren tb8 rb8 ti ri sbuf serial port data buffer 99h -------- saddr serial port address a9h -------- saden serial port address enable b9h -------- table 4. special function registers continued * indicates sfrs that are bit addressable. name description sfr address bit functions and addresses [1] msb lsb
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 12 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi [1] unimplemented bits in sfrs (labeled -) are x (unknown) at all times. unless otherwise speci?ed, 1s should not be written to these bits since they may be used for other purposes in future derivatives. the reset values shown for these bits are 0s although they are unknown when read. bit address 87 86 85 84 83 82 81 80 spcr spi control register d5h spie spen dord mstr cpol cpha spr1 spr0 spsr spi status register aah spif wcol - - ---- spdat spi data 86h -------- sp stack pointer 81h -------- bit address 8f 8e 8d 8c 8b 8a 89 88 tcon* timer/counter control 88h tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 bit address cf ce cd cc cb ca c9 c8 t2con* timer/counter 2 control c8h tf2 exf2 rclk tclk exen2 tr2 c/ t2 cp/ rl2 t2mod timer 2 mode control c9h ------ t2oe dcen th0 timer 0 high 8ch -------- th1 timer 1 high 8dh -------- th2 timer 2 high cdh -------- tl0 timer 0 low 8ah -------- tl1 timer 1 low 8bh -------- tl2 timer 2 low cch -------- tmod timer/counter 0 and 1 mode 89h t1gate t1c/ t t1m1 t1m0 t0gate t0c/ t t0m1 t0m0 wdtrst watchdog timer reset a6h -------- table 4. special function registers continued * indicates sfrs that are bit addressable. name description sfr address bit functions and addresses [1] msb lsb
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 13 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.2 memory organization the various p89cv51rb2/rc2/rd2 memory spaces are as follows: ? data 128 b of internal data memory space (00h:7fh) accessed via direct or indirect addressing, using instructions other than movx and movc. all or part of the stack may be in this area. ? i data indirect data. 256 b of internal data memory space (00h:ffh) accessed via indirect addressing using instructions other than movx and movc. all or part of the stack may be in this area. this area includes the data area and the 128 b immediately above it. ? sfr special function registers. selected cpu registers and peripheral control and status registers, accessible only via direct addressing. ? x data external data or auxiliary ram. duplicates the classic 80c51 64 kb memory space addressed via the movx instruction using the dptr, r0, or r1. the p89cv51rb2/rc2/rd2 have 768 b of on-chip xdata memory. ? code 64 kb of code memory space, accessed as part of program execution and via the movc instruction. the p89cv51rb2/rc2/rd2 have 16/32/64 kb of on-chip code memory. 6.2.1 expanded data ram addressing the p89cv51rb2/rc2/rd2 have 1 kb of data ram; see figure 4 . to access the expanded ram (xram), the extram bit must be set and movx instructions must be used. the expanded memory is physically located on the chip and logically occupies the ?rst bytes of external memory (addresses 000h to 2ffh). when extram = 0, the expanded ram is indirectly addressed using the movx instruction in combination with any of the registers r0, r1 of the selected bank or dptr. accessing the expanded ram does not affect ports p0, p3[6] ( wr), p3[7] ( rd), or p2. with extram = 0, the expanded ram can be accessed as in the following example. expanded ram access (indirect addressing only): movx @dptr, a; dptr contains 0a0h table 5. auxr - auxiliary function register (address 8eh) bit allocation not bit addressable; reset value 00h. bit 7 6 5 4 3 2 1 0 symbol - - - - - - extram ao
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 14 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi the dptr points to location 0a0h and the data in the accumulator is written to address 0a0h of the expanded ram rather than off-chip external memory. access to extram addresses that are not present on the device (above 2ffh) will access external off-chip memory and will perform in the same way as the standard 8051, with p0 and p2 as data/address bus, and p3[6] and p3[7] as write and read timing signals. when extram = 1, movx @ri and movx @dptr will be similar to the standard 8051. using movx @ri provides an 8-bit address with multiplexed data on port 0. other output port pins can be used to output higher order address bits. this provides external paging capabilities. using movx @dptr generates a 16-bit address. this allows external addressing up to 64 kb. port 2 provides the high-order eight address bits (dph), and port 0 multiplexes the low-order eight address bits (dpl) with data. both movx @ri and movx @dptr generates the necessary read and write signals (p3[6] - wr and p3[7] - rd) for external memory use. t ab le 7 shows external data memory rd, wr operation with extram bit. the stack pointer (sp) can be located anywhere within the 256 b of internal ram (lower 128 b and upper 128 b). the stack pointer may not be located in any part of the expanded ram. table 6. auxr - auxiliary function register (address 8eh) bit description bit symbol description 7 to 2 - reserved for future use. should be set to 0 by user programs. 1 extram internal/external ram access using movx @ri/@dptr. when 0, accesses internal xram with address speci?ed in movx instruction. if address supplied with this instruction exceeds on-chip available xram, off-chip ram is accessed. when 1, every movx instruction targets external data memory by default. 0 ao ale off: disables/enables ale. ao = 0 results in ale emitted at a constant rate of 1 2 the oscillator frequency. in case of ao = 1, ale is active only during a movx or movc. table 7. external data memory rd, wr with extram bit auxr movx @dptr, a or movx a, @dptr movx @ri, a or movx a, @ri addr < 0300h addr 3 0300h addr = any extram = 1 rd/ wr asserted rd/ wr asserted rd/ wr asserted extram = 0 rd/ wr not asserted rd/ wr asserted rd/ wr not asserted
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 15 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.2.2 dual data pointers the device has two 16-bit data pointers. the dptr select (dps) bit in auxr1 determines which of the two data pointers is accessed. when dps = 0, dptr0 is selected; when dps = 1, dptr1 is selected. quickly switching between the two data pointers can be accomplished by a single inc instruction on auxr1; see figure 5 . fig 4. internal and external data memory structure 000h 2ffh 00h ffh upper 128 b internal ram lower 128 b internal ram (indirect and direct addressing) (indirect addressing) (direct addressing) special function registers (sfrs) 80h ffh ffffh 000h external data memory external data memory 2ffh 0000h extram = 0 extram = 1 expanded ram 0300h (indirect addressing) (indirect addressing) (indirect addressing) ffffh 80h 7fh 002aaa517 expanded ram 768 b
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 16 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.2.3 reset at initial power-up, the port pins will be in a random state until the oscillator has started and the internal reset algorithm has weakly pulled all pins high. powering up the device without a valid reset could cause the mcu to start executing instructions from an indeterminate location. such unde?ned states may inadvertently corrupt the code in the ?ash. a system reset will not affect the on-chip ram while the device is running, however, the contents of the on-chip ram during power-up are indeterminate. when power is applied to the device, the rst pin must be held high long enough for the oscillator to start-up (usually several milliseconds for a low frequency crystal), in addition to two machine cycles for a valid power-on reset. an example of a method to extend the rst signal is to implement an rc circuit by connecting the rst pin to v dd through a 10 m f capacitor and to v ss through an 8.2 k w resistor as shown in figure 6 . during initial power-up the pof ?ag in the pcon register is set to indicate an initial power-up condition. the pof ?ag will remain active until cleared by software. fig 5. dual data pointer organization table 8. auxr1 - auxiliary function register 1 (address a2h) bit allocation not bit addressable; reset value 00h. bit 7 6 5 4 3 2 1 0 symbol - - enboot - gf2 0 - dps table 9. auxr1 - auxiliary function register 1 (address a2h) bit description bit symbol description 7, 6, 4 - reserved for future use. should be set to 0 by user programs. 5 enboot enable bootrom 3 gf2 general purpose user-de?ned flag. 2 0 this bit contains a hard-wired 0. allows toggling of the dps bit by incrementing auxr1, without interfering with other bits in the register. 1 - reserved for future use. should be set to 0 by user programs. 0 dps data pointer select. chooses one of two data pointers for use by the program. see text for details. dpl 82h dps = 0 ? dptr0 dps = 1 ? dptr1 external data memory dps 002aaa518 dph 83h dptr0 dptr1 auxr1 / bit0
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 17 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi following a reset condition, under normal conditions, the mcu will start executing code from address 0000h in the users code memory. however if either the psen pin was low when reset was exited, or the status bit = 1, the mcu will start executing code from the boot address. the boot address is formed using the value of the boot vector as the high byte of the address and 00h as the low byte. 6.3 flash memory 6.3.1 flash organization the p89cv51rb2/rc2/rd2 program memory consists of a 16/32/64 kb block for user code. the ?ash can be read or written in bytes and can be erased in 128-b pages. a chip erase function will erase the entire user code memory and its associated security bits. there are three methods for erasing or programming the ?ash memory that may be used. first, the ?ash may be programmed or erased in the end-user application by calling low-state routines through a common iap entry point. second, the on-chip isp bootloader may be invoked. this isp bootloader will, in turn, call low-state routines through the same common entry point that can be used by the end-user application. third, the ?ash may be programmed or erased using the parallel method by using a commercially available eprom programmer which supports this device. 6.3.2 features ? flash internal program memory with 128-b page erase. ? internal boot block, containing low-state iap routines available to user code. ? boot vector allows user-provided ?ash loader code to reside anywhere in the ?ash memory space, providing ?exibility to the user. ? default loader providing isp via the serial port, located in upper-end of program memory. ? programming and erase over the full operating voltage range. ? read/programming/erase using isp/iap. fig 6. power-on reset circuit 002aaa543 v dd v dd 8.2 k w rst xtal2 xtal1 c 1 c 2 10 m f
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 18 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi ? programming with industry-standard commercial programmers. ? 10000 typical erase/program cycles for each byte. ? 100 year minimum data retention. 6.3.3 boot block when the microcontroller programs its own ?ash memory, all of the low-level details are handled by code (bootloader) that is contained in a boot block. a user program calls the common entry point in the boot block with appropriate parameters to accomplish the desired operation. boot block operations include erase user code, program user code, program security bits, chip erase, etc. the boot block logically overlays the program memory space from fc00h to ffffh, when it is enabled. the boot block may be disabled on-the-?y so that the upper 1 kb of user code is available to the users program. 6.3.4 power-on reset code execution the p89cv51rb2/rc2/rd2 contains two special ?ash elements: the boot vector and the boot status bit. following reset, the p89cv51rb2/rc2/rd2 examines the contents of the boot status bit. if the boot status bit is set to zero, power-up execution starts at location 0000h, which is the normal start address of the users application code. when the boot status bit is set to a value other than zero, the contents of the boot vector are used as the high byte of the execution address and the low byte is set to 00h. t ab le 10 shows the factory default boot vector setting for this device. a factory-provided bootloader is pre-programmed into the address space indicated and uses the indicated bootloader entry point to perform isp functions. 6.3.5 hardware activation of the bootloader the bootloader can also be executed by forcing the device into isp mode during a power-on sequence. this has the same effect as having a non-zero status byte. this allows an application to be built that will normally execute user code but can be manually forced into isp operation. this occurs by holding psen low at the falling edge of reset. if the factory default setting for the boot vector (fch) is changed, it will no longer point to the factory pre-programmed isp bootloader code. after programming the ?ash, the status byte should be programmed to zero in order to allow execution of the users application code beginning at address 0000h. 6.3.6 isp isp is performed without removing the microcontroller from the system. the isp facility consists of a series of internal hardware resources coupled with internal ?rmware to facilitate remote programming of the p89cv51rb2/rc2/rd2 through the serial port. this ?rmware is provided by nxp and embedded within each p89cv51rb2/rc2/rd2 device. the nxp isp facility has made in-circuit programming in an embedded application possible with a minimum of additional expense in components and circuit board area. the isp function uses ?ve pins (v dd , v ss , txd, rxd, and rst). only a small connector needs to be available to interface your application to an external circuit in order to use this feature. table 10. default boot vector values and isp entry points device default boot vector default bootloader entry point default bootloader code range p89cv51rb2/rc2/rd2 fch fc00h fc00h to ffffh
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 19 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.3.7 using isp the isp feature allows for a wide range of baud rates to be used in your application, independent of the oscillator frequency. it is also adaptable to a wide range of oscillator frequencies. this is accomplished by measuring the bit-time of a single bit in a received character. this information is then used to program the baud rate in terms of timer counts based on the oscillator frequency. the isp feature requires that an initial character (an uppercase u) be sent to the p89cv51rb2/rc2/rd2 to establish the baud rate. the isp ?rmware provides auto-echo of received characters. once baud rate initialization has been performed, the isp ?rmware will only accept intel hex-type records. intel hex records consist of ascii characters used to represent hexadecimal values and are summarized below: :nnaaaarrdd..ddcc in the intel hex record, the nn represents the number of data bytes in the record. the p89cv51rb2/rc2/rd2 will accept up to 32 data bytes. the aaaa string represents the address of the ?rst byte in the record. if there are zero bytes in the record, this ?eld is often set to 0000. the rr string indicates the record type. a record type of 00 is a data record. a record type of 01 indicates the end-of-?le mark. in this application, additional record types will be added to indicate either commands or data for the isp facility. the maximum number of data bytes in a record is limited to 32 (decimal). isp commands are summarized in t ab le 11 . as a record is received by the p89cv51rb2/rc2/rd2, the information in the record is stored internally and a checksum calculation is performed. the operation indicated by the record type is not performed until the entire record has been received. should an error occur in the checksum, the p89cv51rb2/rc2/rd2 will send an x out the serial port indicating a checksum error. if the checksum calculation is found to match the checksum in the record, then the command will be executed. in most cases, successful reception of the record will be indicated by transmitting a . character out the serial port.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 20 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi table 11. isp hex record formats record type command/data function 00 program user code memory :nnaaaa00dd..ddcc where: nn = number of bytes to program aaaa = address dd..dd = data bytes cc = checksum example: :09000000010203040506070809ca 01 end of file (eof), no operation :xxxxxx01cc where: xxxxxx = required ?eld but value is a dont care cc = checksum example: :00000001ff 02 not used
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 21 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 03 miscellaneous write functions :nnxxxx03ffssddcc where: nn = number of bytes in the record xxxx = required ?eld but value is a dont care ff = subfunction code ss = selection code dd = data (if needed) cc = checksum subfunction code = 0c (erase 4 kb blocks) ff=0c ss = block code, as shown below: block 0, 0 kb to 4 kb, 00h block 1, 4 kb to 8 kb, 10h block 2, 8 kb to 12 kb, 20h block 3, 12 kb to 16 kb, 30h block 4, 16 kb to 20 kb, 40h (only available on p89cv51rc2/rd2) block 5, 20 kb to 24 kb, 50h (only available on p89cv51rc2/rd2) block 6, 24 kb to 28 kb, 60h (only available on p89cv51rc2/rd2) block 7, 28 kb to 32 kb, 70h (only available on p89cv51rc2/rd2) block 8, 32 kb to 36 kb, 80h (only available on p89cv51rd2) block 9, 36 kb to 40 kb, 90h (only available on p89cv51rd2) block 10, 40 kb to 44 kb, a0h (only available on p89cv51rd2) block 11, 44 kb to 48 kb, b0h (only available on p89cv51rd2) block 12, 48 kb to 52 kb, c0h (only available on p89cv51rd2) block 13, 52 kb to 56 kb, d0h (only available on p89cv51rd2) block 14, 56 kb to 60 kb, e0h (only available on p89cv51rd2) block 15, 60 kb to 64 kb, f0h (only available on p89cv51rd2) example: :020000030c20cf (erase 4 kb block #2) table 11. isp hex record formats continued record type command/data function
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 22 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 03 (continued) subfunction code = 01 (erase blocks) ff=01 ss = block code, as shown below block 0, 0 kb to 8 kb, 00h block 1, 8 kb to 16 kb, 20h block 2, 16 kb to 32 kb, 40h block 3, 32 kb to 48 kb, 80h block 4, 48 kb to 64 kb, c0h subfunction code = 04 (erase boot vector and status bit) ff=04 ss = dont care subfunction code = 05 (program security bits) ff=05 ss = 00 program security bit 1 ss = 01 program security bit 2 ss = 02 program security bit 3 subfunction code = 06 (program status bit, boot vector, 6 /12 bit) ff=06 dd = data (for boot vector) ss = 00 program status bit ss = 01 program boot vector ss = 02 program 6 /12 bit subfunction code = 07 (chip erase) erases code memory and security bits, programs default boot vector and status bit ff=07 subfunction code = 08 (erase page, 128 b) ff=08 ss = high byte of page address (a[15:8]) dd = low byte of page address (a[7:0]) example: :0300000308e000f2 (erase page at e000h) table 11. isp hex record formats continued record type command/data function
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 23 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 04 display device data or blank check :05xxxx04sssseeeeffcc where 05 = number of bytes in the record xxxx = required ?eld but value is a dont care 04 = function code for display or blank check ssss = starting address, msb ?rst eeee = ending address, msb ?rst ff = subfunction 00 = display data 01 = blank check cc = checksum subfunction codes: example: :0500000400001fff00d9 (display from 0000h to 1fffh) 05 miscellaneous read functions :02xxxx05ffsscc where: 02 = number of bytes in the record xxxx = required ?eld but value is a dont care 05 = function code for miscellaneous read ffss = subfunction and selection code 0000 = read manufacturer id 0001 = read device id 1 0002 = read device id 2 0003 = read 6 /12 bit (bit 7 = 1 is 6 , bit 7 = 0 is 12 ) 0080 = read boot code version 0700 = read security bits 0701 = read status bit 0702 = read boot vector cc = checksum example: :020000050000f9 (display manufacturer id) 06 direct load of baud rate :02xxxx06hhllcc where: 02 = number of bytes in the record xxxx = required ?eld but value is a dont care hh = high byte of timer t2 ll = low byte of timer t2 cc = checksum example: :02000006ffffcc (load t2 = ffff) table 11. isp hex record formats continued record type command/data function
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 24 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.3.8 iap method several iap calls are available for use by an application program to permit selective erasing, reading and programming of ?ash pages, security bits, status bit, and device id. all calls are made through a common interface, pgm_mtp. the programming functions are selected by setting up the microcontrollers registers before making a call to pgm_mtp at fff0h. the iap calls are shown in t ab le 12 . table 12. iap function calls iap function iap call parameters read id input parameters: r1 = 00h or 80h (wdt feed) dph = 00h dpl = 00h = manufacturer id dpl = 01h = device id 1 dpl = 02h = device id 2 dpl = 03h = 6 /12 bit (if bit 7 = 1: 6 ) dpl = 80h = isp version number return parameter(s): acc = requested parameter erase 4 kb code block (new function) input parameters: r0 = oscillator frequency (integer) r1 = 0ch or 8ch (wdt feed) dph = address of 4 kb code block dph = 00h, 4 kb block 0, 0 kb to 4 kb dph = 10h, 4 kb block 1, 4 kb to 8 kb dph = 20h, 4 kb block 2, 8 kb to 12 kb dph = 30h, 4 kb block 3, 12 kb to 16 kb dph = 40h, 4 kb block 4, 16 kb to 20 kb dph = 50h, 4 kb block 5, 20 kb to 24 kb dph = 60h, 4 kb block 6, 24 kb to 28 kb dph = 70h, 4 kb block 7, 28 kb to 32 kb dph = 80h, 4 kb block 8, 32 kb to 36 kb dph = 90h, 4 kb block 9, 36 kb to 40 kb dph = a0h, 4 kb block 10, 40 kb to 44 kb dph = b0h, 4 kb block 11, 44 kb to 48 kb dph = c0h, 4 kb block 12, 48 kb to 52 kb dph = d0h, 4 kb block 13, 52 kb to 56 kb dph = e0h, 4 kb block 14, 56 kb to 60 kb dph = f0h, 4 kb block 15, 60 kb to 64 kb dpl = 00h return parameter(s): acc = 00: pass acc is not 00: fail
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 25 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi erase 8 kb/16 kb code block input parameters: r1 = 01h or 81h (wdt feed) dph = 00h, block 0, 0 kb to 8 kb dph = 20h, block 1, 8 kb to 16 kb dph = 40h, block 2, 16 kb to 32 kb dph = 80h, block 3, 32 kb to 48 kb dph = c0h, block 4, 48 kb to 64 kb return parameter(s): acc = 00: pass acc is not 00: fail program user code input parameters: r1 = 02h or 82h (wdt feed) dph = memory address msb dpl = memory address lsb acc = byte to program return parameter(s): acc = 00: pass acc is not 00: fail read user code input parameters: r1 = 03h or 83h (wdt feed) dph = memory address msb dpl = memory address lsb return parameter(s): acc = device data erase status bit and boot vector input parameters: r1 = 04h or 84h (wdt feed) dpl = dont care dph = dont care return parameter(s): acc = 00: pass acc is not 00: fail program security bits input parameters: r1 = 05h or 85h (wdt feed) dpl = 00h = security bit 1 dpl = 01h = security bit 2 dpl = 02h = security bit 3 return parameter(s): acc = 00: pass acc is not 00: fail table 12. iap function calls continued iap function iap call parameters
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 26 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.4 timers/counters 0 and 1 the two 16-bit timer/counter registers: timer 0 and timer 1 can be con?gured to operate either as timers or event counters (see t ab le 13 and t ab le 14 ). in the timer function, the register is incremented every machine cycle. thus, one can think of it as counting machine cycles. since a machine cycle consists of six oscillator periods, the count rate is 1 6 of the oscillator frequency. in the counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, t0 or t1. in this function, the external input is sampled once every machine cycle. when the samples show a high in one cycle and a low in the next cycle, the count is incremented. the new count value appears in the register in the machine cycle following the one in which the transition was detected. since it takes two machine cycles (12 oscillator periods) for a 1-to-0 transition to be recognized, the maximum count rate is 1 12 of the oscillator frequency. there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it should be held for at least one full machine cycle. in addition to the timer or counter selection, timer 0 and timer 1 have four selectable operating modes. program status bit, boot vector, 6 /12 bit input parameters: r1 = 06h or 86h (wdt feed) dpl = 00h = program status bit dpl = 01h = program boot vector dpl = 02h = 6 /12 bit acc = boot vector value to program return parameter(s): acc = 00: pass acc is not 00: fail read security bits, status bit, boot vector input parameters: acc = 07h or 87h (wdt feed) dpl = 00h = security bits dpl = 01h = status bit dpl = 02h = boot vector return parameter(s): acc = 00 softice s/n-match 0 sb 0 dbl_clk erase page input parameters: r1 = 08h or 88h (wdt feed) dph = page address high byte dpl = page address low byte return parameter(s): acc = 00: pass acc is not 00: fail table 12. iap function calls continued iap function iap call parameters
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 27 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi the timer or counter function is selected by control bits c/ t in the special function register tmod. these two timers/counters have four operating modes, which are selected by bit-pairs (m1, m0) in tmod. modes 0, 1, and 2 are the same for both timers/counters. mode 3 is different. the four operating modes are described in the following text. table 13. tmod - timer/counter mode control register (address 89h) bit allocation not bit addressable; reset value: 0000 0000b; reset source(s): any source. bit 7 6 5 4 3 2 1 0 symbol t1gate t1c/ t t1m1 t1m0 t0gate t0c/ t t0m1 t0m0 table 14. tmod - timer/counter mode control register (address 89h) bit description bit symbol description 7 t1gate gating control for timer 1. when set, timer/counter is enabled only while the int1 pin is high and the tr1 control bit is set. when cleared, timer 1 is enabled when the tr1 control bit is set. 6 t1c/ t timer or counter select for timer 1. cleared for timer operation. set for counter operation (input from t1 input pin). 5 t1m1 mode select for timer 1. 4 t1m0 3 t0gate gating control for timer 0. when set, timer/counter is enabled only while the int0 pin is high and the tr0 control bit is set. when cleared, timer 0 is enabled when the tr0 control bit is set. 2 t0c/ t timer or counter select for timer 0. cleared for timer operation. set for counter operation (input from t0 input pin). 1 t0m1 mode select for timer 0. 0 t0m0 table 15. tmod - timer/counter mode control register (address 89h) m1/m0 operating mode m1 m0 operating mode 0 0 0 8048 timer tlx serves as 5-bit prescaler. 0 1 1 16-bit timer/counter thx and tlx' are cascaded; there is no prescaler. 1 0 2 8-bit auto-reload timer/counter thx holds a value which is to be reloaded into tlx each time it over?ows. 1 1 3 (timer 0) tl0 is an 8-bit timer/counter controlled by the standard timer 0 control bits. th0 is an 8-bit timer only controlled by timer 1 control bits. 1 1 3 (timer 1) timer/counter 1 stopped. table 16. tcon - timer/counter control register (address 88h) bit allocation bit addressable; reset value: 0000 0000b; reset source(s): any reset. bit 7 6 5 4 3 2 1 0 symbol tf1 tr1 tf0 tr0 ie1 it1 ie0 it0
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 28 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.4.1 mode 0 putting either timer into mode 0 makes it look like an 8048 timer, which is an 8-bit counter with a ?xed divide-by-32 prescaler. figure 7 shows mode 0 operation. in this mode, the timer register is con?gured as a 13-bit register. as the count rolls over from all 1s to all 0s, it sets the timer interrupt ?ag tfn. the count input is enabled to the timer when trn = 1 and either gate = 0 or intn = 1. (setting gate = 1 allows the timer to be controlled by external input intn, to facilitate pulse width measurements). trn is a control bit in the special function register tcon ( t ab le 17 ). the gate bit is in the tmod register. the 13-bit register consists of all 8 bits of thn and the lower 5 bits of tln. the upper 3 bits of tln are indeterminate and should be ignored. setting the run ?ag (trn) does not clear the registers. mode 0 operation is the same for timer 0 and timer 1; see figure 7 . there are two different gate bits, one for timer 1 (tmod.7) and one for timer 0 (tmod.3). table 17. tcon - timer/counter control register (address 88h) bit description bit symbol description 7 tf1 timer 1 over?ow flag. set by hardware on timer/counter over?ow. cleared by hardware when the processor vectors to timer 1 interrupt routine, or by software. 6 tr1 timer 1 run control bit. set/cleared by software to turn timer/counter 1 on/off. 5 tf0 timer 0 over?ow flag. set by hardware on timer/counter over?ow. cleared by hardware when the processor vectors to timer 0 interrupt routine, or by software. 4 tr0 timer 0 run control bit. set/cleared by software to turn timer/counter 0 on/off. 3 ie1 interrupt 1 edge ?ag. set by hardware when external interrupt 1 edge/low-state is detected. cleared by hardware when the interrupt is processed, or by software. 2 it1 interrupt 1 type control bit. set/cleared by software to specify falling edge/low-state that triggers external interrupt 1. 1 ie0 interrupt 0 edge ?ag. set by hardware when external interrupt 0 edge/low-state is detected. cleared by hardware when the interrupt is processed, or by software. 0 it0 interrupt 0 type control bit. set/cleared by software to specify falling edge/low-state that triggers external interrupt 0. fig 7. timer/counter 0 or 1 in mode 0 (13-bit counter) 002aaa519 osc/6 tn pin trn tngate intn pin c/t = 0 c/t = 1 tln (5-bits) thn (8-bits) tfn control overflow interrupt
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 29 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.4.2 mode 1 mode 1 is the same as mode 0, except that all 16 bits of the timer register (thn and tln) are used; see figure 8 . 6.4.3 mode 2 mode 2 con?gures the timer register as an 8-bit counter (tln) with automatic reload, as shown in figure 9 . over?ow from tln not only sets tfn, but also reloads tln with the contents of thn, which must be preset by software. the reload leaves thn unchanged. mode 2 operation is the same for timer 0 and timer 1. 6.4.4 mode 3 when timer 1 is in mode 3 it is stopped (holds its count). the effect is the same as setting tr1=0. timer 0 in mode 3 establishes tl0 and th0 as two separate 8-bit counters. the logic for mode 3 and timer 0 is shown in figure 10 . tl0 uses the timer 0 control bits: t0c/ t, t0gate, tr0, int0, and tf0. th0 is locked into a timer function (counting machine cycles) and takes over the use of tr1 and tf1 from timer 1. thus, th0 now controls the timer 1 interrupt. mode 3 is provided for applications that require an extra 8-bit timer. with timer 0 in mode 3, the p89cv51rb2/rc2/rd2 can look like it has an additional timer. note: when timer 0 is in mode 3, timer 1 can be turned on and off by switching it into and out of its own mode 3. it can still be used by the serial port as a baud rate generator, or in any application not requiring an interrupt. fig 8. timer/counter 0 or 1 in mode 1 (16-bit counter) 002aaa520 osc/6 tn pin trn tngate intn pin c/t = 0 c/t = 1 tln (8-bits) thn (8-bits) tfn control overflow interrupt fig 9. timer/counter 0 or 1 in mode 2 (8-bit auto-reload) 002aaa521 osc/6 tn pin trn tngate intn pin tln (8-bits) thn (8-bits) tfn control overflow reload interrupt c/t = 0 c/t = 1
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 30 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.5 timer 2 timer 2 is a 16-bit timer/counter which can operate as either an event timer or an event counter, as selected by c/ t2 in the special function register t2con. timer 2 has four operating modes: capture, auto-reload (up or down counting), clock-out, and baud rate generator which are selected according to t ab le 18 using t2con ( t ab le 19 and t ab le 20 ) and t2mod ( t ab le 21 and t ab le 22 ). fig 10. timer/counter 0 mode 3 (two 8-bit counters) 002aaa522 osc/2 tr1 tr0 tngate int0 pin tl0 (8-bits) tf0 control overflow interrupt th0 (8-bits) tf1 control overflow interrupt osc/6 t0 pin c/t = 0 c/t = 1 table 18. timer 2 operating mode rclk + tclk cp/ rl2 tr2 t2oe mode 0 0 1 0 16-bit auto reload 0 1 1 0 16-bit capture 0 0 1 1 programmable clock-out 1 x 1 0 baud rate generator x x 0 x off table 19. t2con - timer/counter 2 control register (address c8h) bit allocation bit addressable; reset value: 00h. bit 7 6 5 4 3 2 1 0 symbol tf2 exf2 rclk tclk exen2 tr2 c/ t2 cp/ rl2 table 20. t2con - timer/counter 2 control register (address c8h) bit description bit symbol description 7 tf2 timer 2 over?ow ?ag set by a timer 2 over?ow and must be cleared by software. tf2 will not be set when either rclk or tclk = 1 or when timer 2 is in clock-out mode. 6 exf2 timer 2 external ?ag is set when timer 2 is in capture, reload or baud rate mode, exen2 = 1 and a negative transition on t2ex occurs. if timer 2 interrupt is enabled exf2 = 1 causes the cpu to vector to the timer 2 interrupt routine. exf2 must be cleared by software. 5 rclk receive clock ?ag. when set, causes the uart to use timer 2 over?ow pulses for its receive clock in modes 1 and 3. rclk = 0 causes timer 1 over?ow to be used for the receive clock.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 31 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.5.1 capture mode in the capture mode there are two options which are selected by bit exen2 in t2con. if exen2 = 0 timer 2 is a 16-bit timer or counter (as selected by c/ t2 in t2con) which upon over?owing sets bit tf2, the timer 2 over?ow bit. the capture mode is illustrated in figure 11 . this bit can be used to generate an interrupt (by enabling the timer 2 interrupt bit et2 in the ie register). if exen2 = 1, timer 2 operates as described above, but with the added feature that a 1-to-0 transition at external input t2ex causes the current value in the timer 2 registers, tl2 and th2, to be captured into registers rcap2l and rcap2h, respectively. in addition, the transition at t2ex causes bit exf2 in t2con to be set, and exf2 like tf2 can generate an interrupt (which vectors to the same location as timer 2 over?ow interrupt). the timer 2 interrupt service routine can interrogate tf2 and exf2 to determine which event caused the interrupt. 4 tclk transmit clock ?ag. when set, causes the uart to use timer 2 over?ow pulses for its transmit clock in modes 1 and 3. tclk = 0 causes timer 1 over?ows to be used for the transmit clock. 3 exen2 timer 2 external enable ?ag. when set, allows a capture or reload to occur as a result of a negative transition on t2ex if timer 2 is not being used to clock the serial port. exen2 = 0 causes timer 2 to ignore events at t2ex. 2 tr2 start/stop control for timer 2. a logic 1 enables the timer to run. 1c/ t2 timer or counter select. (timer 2) 0 = internal timer (f osc /6) 1 = external event counter (falling edge triggered; external clocks maximum rate = f osc / 12) 0 cp/ rl2 capture/reload ?ag. when set, captures will occur on negative transitions at t2ex if exen2 = 1. when cleared, auto-reloads will occur either with timer 2 over?ows or negative transitions at t2ex when exen2 = 1. when either rclk = 1 or tclk = 1, this bit is ignored and the timer is forced to auto-reload on timer 2 over?ow. table 21. t2mod - timer 2 mode control register (address c9h) bit allocation not bit addressable; reset value: xx00 0000b. bit 7 6 5 4 3 2 1 0 symbol - - - - - - t2oe dcen table 22. t2mod - timer 2 mode control register (address c9h) bit description bit symbol description 7 to 2 - reserved for future use. should be set to 0 by user programs. 1 t2oe timer 2 output enable bit. used in programmable clock-out mode only. 0 dcen down count enable bit. when set, this allows timer 2 to be con?gured as an up/down counter. table 20. t2con - timer/counter 2 control register (address c8h) bit description continued bit symbol description
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 32 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi there is no reload value for tl2 and th2 in this mode. even when a capture event occurs from t2ex, the counter keeps on counting t2 pin transitions or f osc / 6 pulses. since once loaded contents of rcap2l and rcap2h registers are not protected, once timer 2 interrupt is signalled it has to be serviced before a new capture event on t2ex pin occurs. otherwise, the next falling edge on t2ex pin will initiate reload of the current value from tl2 and th2 to rcap2l and rcap2h and consequently corrupt their content related to the previously reported interrupt. 6.5.2 auto-reload mode (up or down counter) in the 16-bit auto-reload mode, timer 2 can be con?gured as either a timer or counter (via c/ t2 in t2con), then programmed to count up or down. the counting direction is determined by bit dcen (down counter enable) which is located in the t2mod register (see t ab le 21 and t ab le 22 ). when reset is applied, dcen = 0 and timer 2 will default to counting up. if the dcen bit is set, timer 2 can count up or down depending on the value of the t2ex pin. figure 12 shows timer 2 counting up automatically (dcen = 0). fig 11. timer 2 in capture mode 002aaa523 osc ? 6 t2 pin c/t2 = 0 c/t2 = 1 tl2 (8-bits) th2 (8-bits) tf2 control capture tr2 timer 2 interrupt exf2 rcap2l rcap2h control exen2 transition detector t2ex pin fig 12. timer 2 in auto-reload mode (dcen = 0) 002aaa524 osc ? 6 t2 pin c/t2 = 0 c/t2 = 1 tl2 (8-bits) th2 (8-bits) tf2 control reload tr2 timer 2 interrupt exf2 rcap2l rcap2h control exen2 transition detector t2ex pin
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 33 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi in this mode, there are two options selected by bit exen2 in t2con register. if exen2 = 0, then timer 2 counts up to 0ffffh and sets the tf2 (over?ow ?ag) bit upon over?ow. this causes the timer 2 registers to be reloaded with the 16-bit value in rcap2l and rcap2h. the values in rcap2l and rcap2h are preset by software means. auto reload frequency when timer 2 is counting up can be determined from equation 1 : (1) where supplyfrequency is either f osc (c/ t2 = 0) or frequency of signal on t2 pin (c/ t2 = 1). if exen2 = 1, a 16-bit reload can be triggered either by an over?ow or by a 1-to-0 transition at input t2ex. this transition also sets the exf2 bit. the timer 2 interrupt, if enabled, can be generated when either tf2 or exf2 is 1. the microcontrollers hardware will need three consecutive machine cycles in order to recognize falling edge on t2ex and set exf2 = 1: in the ?rst machine cycle pin t2ex has to be sampled as 1; in the second machine cycle it has to be sampled as 0, and in the third machine cycle exf2 will be set to 1. in figure 13 , dcen = 1 and timer 2 is enabled to count up or down. this mode allows pin t2ex to control the direction of count. when a logic 1 is applied at pin t2ex timer 2 will count up. timer 2 will over?ow at 0ffffh and set the tf2 ?ag, which can then generate an interrupt, if the interrupt is enabled. this timer over?ow also causes the 16-bit value in rcap2l and rcap2h to be reloaded into the timer registers tl2 and th2. when a logic 0 is applied at pin t2ex this causes timer 2 to count down. the timer will under?ow when tl2 and th2 become equal to the value stored in rcap2l and rcap2h. timer 2 under?ow sets the tf2 ?ag and causes 0ffffh to be reloaded into the timer registers tl2 and th2. the external ?ag exf2 toggles when timer 2 under?ows or over?ows. this exf2 bit can be used as a 17th bit of resolution if needed. supplyfrequency 65536 rcap2h rcap2l , () C ---------------------------------------------------------------------------- fig 13. timer 2 in auto reload mode (dcen = 1) 002aaa525 tl2 (8-bits) th2 (8-bits) tf2 exf2 underflow timer 2 interrupt rcap2l rcap2h ffh ffh overflow (down-counting reload value) (up-counting reload value) count direction 1 = up 0 = down t2ex pin toggle osc ? 6 t2 pin c/t2 = 0 c/t2 = 1 control tr2
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 34 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.5.3 programmable clock-out a 50 % duty cycle clock can be programmed to come out on pin t2 (p1[0], clock-out mode). this pin, besides being a regular i/o pin, has two additional functions. it can be programmed: 1. to input the external clock for timer/counter 2, or 2. to output a 50 % duty cycle clock ranging from 122 hz to 8 mhz at a 16 mhz operating frequency. to con?gure the timer/counter 2 as a clock generator, bit c/ t2 (in t2con) must be cleared and bit t2oe in t2mod must be set. bit tr2 (t2con.2) also must be set to start the timer. the clock-out frequency depends on the oscillator frequency and the reload value of timer 2 capture registers (rcap2h, rcap2l) as shown in equation 2 : (2) where (rcap2h, rcap2l) = the content of rcap2h and rcap2l taken as a 16-bit unsigned integer. in the clock-out mode, timer 2 roll-overs will not generate an interrupt. this is similar to when it is used as a baud rate generator. 6.5.4 baud rate generator mode bits tclk and/or rclk in t2con allow the uart transmit and receive baud rates to be derived from either timer 1 or timer 2; see section 6.6 for details. when tclk = 0, timer 1 is used as the uart transmit baud rate generator. when tclk = 1, timer 2 is used as the uart transmit baud rate generator. rclk has the same effect for the uart receive baud rate. with these two bits, the serial port can have different receive and transmit baud rates, timer 1 or timer 2. figure 14 shows timer 2 in baud rate generator mode: oscillatorfrequency 2 65536 rcap2h rcap2l , () C () ------------------------------------------------------------------------------------------ fig 14. timer 2 in baud rate generator mode 002aaa526 tx/rx baud rate timer 2 interrupt osc ? 2 t2 pin c/t2 = 0 c/t2 = 1 tl2 (8-bits) th2 (8-bits) control tr2 exf2 rcap2l rcap2h control exen2 transition detector t2ex pin reload
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 35 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi the baud rate generator mode is like the auto-reload mode, when a roll-over in th2 causes the timer 2 registers to be reloaded with the 16-bit value in registers rcap2h and rcap2l, which are preset by software. the baud rates in modes 1 and 3 are determined by timer 2s over?ow rate given below: modes 1 and 3 baud rates = timer 2 over?ow rate / 16 the timer can be con?gured for either timer or counter operation. in many applications, it is con?gured for timer' operation (c/ t2 = 0). timer operation is different for timer 2 when it is being used as a baud rate generator. usually, as a timer it would increment at every machine cycle (i.e., 1 6 the oscillator frequency). as a baud rate generator, it increments at the oscillator frequency. thus the baud rate formula is shown in equation 3 : modes 1 and 3 baud rates = (3) where: (rcap2h, rcap2l) = the content of rcap2h and rcap2l taken as a 16-bit unsigned integer. the timer 2 in baud rate generator mode is valid only if rclk and/or tclk = 1 in t2con register. note that a roll-over in th2 does not set tf2, and will not generate an interrupt. thus, the timer 2 interrupt does not have to be disabled when timer 2 is in the baud rate generator mode. also if the exen2 (t2 external enable ?ag) is set, a 1-to-0 transition in t2ex (timer/counter 2 trigger input) will set exf2 (t2 external ?ag) but will not cause a reload from (rcap2h, rcap2l) to (th2, tl2). therefore when timer 2 is used as a baud rate generator, t2ex can be used as an additional external interrupt, if needed. when timer 2 is in the baud rate generator mode, one should not try to read or write th2 and tl2. under these conditions, a read or write of th2 or tl2 may not be accurate. the rcap2 registers may be read, but should not be written to, because a write might overlap a reload and cause write and/or reload errors. the timer should be turned off (clear tr2) before accessing the timer 2 or rcap2 registers. t ab le 23 shows commonly used baud rates and how they can be obtained from timer 2. 6.5.5 summary of baud rate equations timer 2 is in baud rate generator mode: if timer 2 is being clocked through pin t2 (p1[0]) the baud rate is: baud rate = timer 2 over?ow rate / 16 if timer 2 is being clocked internally, the baud rate is: baud rate = f osc / (16 (65536 - (rcap2h, rcap2l))) where f osc = oscillator frequency to obtain the reload value for rcap2h and rcap2l, this equation can be rewritten as: rcap2h, rcap2l = 65536 - f osc / (16 baud rate) oscillatorfrequency 16 65536 rcap2h rcap2l , () C () ---------------------------------------------------------------------------------------------
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 36 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.6 uart the uart operates in all standard modes. enhancements over the standard 80c51 uart include framing error detection, and automatic address recognition. 6.6.1 mode 0 serial data enters and exits through rxd, and txd outputs the shift clock. only 8 bits are transmitted or received, lsb ?rst. the baud rate is ?xed at 1 6 of the cpu clock frequency. the uart con?gured to operate in this mode outputs serial clock on the txd line no matter whether it sends or receives data on the rxd line. 6.6.2 mode 1 10 bits are transmitted (through txd) or received (through rxd): a start bit (logical 0), 8 data bits (lsb ?rst), and a stop bit (logical 1). when data is received, the stop bit is stored in rb8 in special function register scon. the baud rate is variable and is determined by the timer 1/timer 2 over?ow rate. 6.6.3 mode 2 11 bits are transmitted (through txd) or received (through rxd): start bit (logical 0), 8 data bits (lsb ?rst), a programmable 9th data bit, and a stop bit (logical 1). when data is transmitted, the 9th data bit (tb8 in special function register scon) can be assigned the value of 0 or (e.g. the parity bit (p in special function register psw) could be moved into bit tb8). when data is received, the 9th data bit goes into rb8 in special function register scon, while the stop bit is ignored. the baud rate is programmable to either 1 16 or 1 32 of the cpu clock frequency, as determined by the smod1 bit in pcon. 6.6.4 mode 3 11 bits are transmitted (through txd) or received (through rxd): a start bit (logical 0), 8 data bits (lsb ?rst), a programmable 9th data bit, and a stop bit (logical 1). in fact, mode 3 is the same as mode 2 in all respects except baud rate. the baud rate in mode 3 is variable and is determined by the timer 1/timer 2 over?ow rate. table 23. timer 2-generated commonly used baud rates rate oscillator frequency timer 2 rcap2h rcap2l 750 kbd 12 mhz ff ff 19.2 kbd 12 mhz ff d9 9.6 kbd 12 mhz ff b2 4.8 kbd 12 mhz ff 64 2.4 kbd 12 mhz fe c8 600 bd 12 mhz fb 1e 220 bd 12 mhz f2 af 600 bd 6 mhz fd 8f 220 bd 6 mhz f9 57
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 37 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.6.5 framing error framing error (fe) is reported in the scon.7 bit if smod0 (pcon.6) = 1. if smod0 = 0, scon.7 is the sm0 bit for the uart, it is recommended that sm0 is set up before smod0 is set to 1. table 24. scon - serial port control register (address 98h) bit allocation bit addressable; reset value: 00h. bit 7 6 5 4 3 2 1 0 symbol sm0/fe sm1 sm2 ren tb8 rb8 ti ri table 25. scon - serial port control register (address 98h) bit description bit symbol description 7 sm0/fe the usage of this bit is determined by smod0 in the pcon register. if smod0 = 0, this bit is sm0, which with sm1, de?nes the serial port mode. if smod0 = 1, this bit is fe (framing error). fe is set by the receiver when an invalid stop bit is detected. once set, this bit cannot be cleared by valid frames but can only be cleared by software. (note: it is recommended to set up uart mode bits sm0 and sm1 before setting smod0 to 1.) 6 sm1 with sm0, de?nes the serial port mode; see t ab le 26 . 5 sm2 enables the multiprocessor communication feature in modes 2 and 3. in mode 2 or 3, if sm2 is set to 1, then ri will not be activated if the received 9th data bit (rb8) is 0. in mode 1, if sm2 = 1 then ri will not be activated if a valid stop bit was not received. in mode 0, sm2 should be 0. 4 ren enables serial reception. set by software to enable reception. clear by software to disable reception. 3 tb8 the 9th data bit that will be transmitted in modes 2 and 3. set or clear by software as desired. 2 rb8 in modes 2 and 3, is the 9th data bit that was received. in mode 1, if sm2 = 0, rb8 is the stop bit that was received. in mode 0, rb8 is unde?ned. 1 ti transmit interrupt ?ag. set by hardware at the end of the 8th bit time in mode 0, or at the stop bit in the other modes, in any serial transmission. must be cleared by software. 0 ri receive interrupt ?ag. set by hardware at the end of the 8th bit time in mode 0, or approximately halfway through the stop bit time in all other modes. (see sm2 for exceptions). must be cleared by software. table 26. scon - serial port control register (address 98h) sm0/sm1 mode de?nition sm0, sm1 uart mode baud rate 0 0 0: shift register cpu clock / 6 0 1 1: 8-bit uart variable 1 0 2: 9-bit uart cpu clock / 32 or cpu clock / 16 1 1 3: 9-bit uart variable
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 38 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.6.6 more about uart mode 1 reception is initiated by a detected 1-to-0 transition at rxd. for this purpose rxd is sampled at a rate of 16 times whatever baud rate has been established. when a transition is detected, the divide-by-16 counter is immediately reset to align its roll-overs with the boundaries of the incoming bit times. the 16 states of the counter divide each bit time into 16ths. at the 7th, 8th, and 9th counter states of each bit time, the bit detector samples the value of rxd. the value accepted is the value that was seen in at least 2 of the 3 samples. this is done for noise rejection. if the value accepted during the ?rst bit time is not 0, the receive circuits are reset and the unit goes back to looking for another 1-to-0 transition. this is to provide rejection of false start bits. if the start bit proves valid, it is shifted into the input shift register, and reception of the rest of the frame will proceed. the signal to load sbuf and rb8, and to set ri, will be generated if, and only if, the following conditions are met at the time the ?nal shift pulse is generated: (a) ri = 0, and (b) either sm2 = 0, or the received stop bit = 1. if either of these two conditions is not met, the received frame is irretrievably lost. if both conditions are met, the stop bit goes into rb8, the 8 data bits go into sbuf, and ri is activated. 6.6.7 more about uart modes 2 and 3 reception is performed in the same manner as in mode 1. the signal to load special function register sbuf and rb8, and to set ri, will be generated if, and only if, the following conditions are met at the time the ?nal shift pulse is generated: (a) ri = 0, and (b) either sm2 = 0, or the received 9th data bit = 1. if either of these conditions is not met, the received frame is irretrievably lost, and ri is not set. if both conditions are met, the received 9th data bit goes into rb8, and the ?rst 8 data bits go into sbuf. 6.6.8 multiprocessor communications uart modes 2 and 3 have a special provision for multiprocessor communications. in these modes, 9 data bits are received or transmitted. when data is received, the 9th bit is stored in rb8. the uart can be programmed so that when the stop bit is received, the serial port interrupt will be activated only if rb8 = 1. this feature is enabled by setting bit sm2 in scon. one way to use this feature in multiprocessor systems is as follows: when the master processor wants to transmit a block of data to one of several slaves, it ?rst sends out an address byte which identi?es the target slave. an address byte differs from a data byte: the 9th bit is 1 in an address byte and 0 in a data byte. with sm2 = 1, no slave will be interrupted by a data byte, i.e. the received 9th bit is 0. however, an address byte having the 9th bit set to 1 will interrupt all slaves, so that each slave can examine the received byte to see if it is being addressed or not. the addressed slave will clear its sm2 bit and prepare to receive the data (still 9 bits long) that follow. the slaves that were not addressed leave their sm2 bits set and ignore the subsequent data bytes.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 39 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi sm2 has no effect in mode 0, and in mode 1 can be used to check the validity of the stop bit, although it is preferable to use the framing error ?ag (fe). when the uart receives data in mode 1 and sm2 = 1, the receive interrupt will not be activated unless a valid stop bit is received. 6.6.9 automatic address recognition automatic address recognition is a feature which allows the uart to recognize certain addresses in the serial bit stream by using hardware to make the comparisons. this feature saves a great deal of software overhead by eliminating the need for the software to examine every serial address which passes by the serial port. this feature is enabled for the uart by setting the sm2 bit in scon. in the 9-bit uart modes, mode 2 and mode 3, the receive interrupt ?ag (ri) will be automatically set when the received byte contains either the given address or the broadcast address. the 9-bit mode requires that the 9th information bit is a 1 to indicate that the received information is an address and not data. using the automatic address recognition feature allows a master to selectively communicate with one or more slaves by invoking the given slave address or addresses. all of the slaves may be contacted by using the broadcast address. two special function registers are used to de?ne the slaves address, saddr, and the address mask, saden. saden is used to de?ne which bits in the saddr are to be used and which bits are dont care. the saden mask can be logically anded with the saddr to create the given address which the master will use for addressing each of the slaves. use of the given address allows multiple slaves to be recognized while excluding others. this device uses the methods presented in figure 15 to determine if a given or broadcast address has been received or not. fig 15. schemes used by the uart to detect given and broadcast addresses when multiprocessor communications is enabled 002aaa527 rx_byte(7) saddr(7) saden(7) rx_byte(0) saddr(0) . . . given_address_match logic used by uart to detect 'given address' in received data saddr(7) saden(7) rx_byte(7) saddr(0) saden(0) rx_byte(0) broadcast_address_match logic used by uart to detect 'given address' in received data saden(0) . . .
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 40 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi the following examples help to show the versatility of this scheme. example 1, slave 0: example 2, slave 1: in the above example saddr is the same and the saden data is used to differentiate between the two slaves. slave 0 requires a 0 in bit 0 and it ignores bit 1. slave 1 requires a 0 in bit 1 and bit 0 is ignored. a unique address for slave 0 would be 1100 0010 since slave 1 requires a 0 in bit 1. a unique address for slave 1 would be 1100 0001 since a 1 in bit 0 will exclude slave 0. both slaves can be selected at the same time by an address which has bi t0=0(forslave0)andbit1=0(forslave1). thus, both could be addressed with 1100 0000. in a more complex system the following could be used to select slaves 1 and 2 while excluding slave 0. example 1, slave 0: example 2, slave 1: example 3, slave 2: in the above example the differentiation among the 3 slaves is in the lower 3 address bits. slave 0 requires that bit 0 = 0 and it can be uniquely addressed by 1110 0110. slave 1 requires that bi t1=0 and it can be uniquely addressed by 1110 0101. slave 2 requires that bit 2 = 0 and its unique address is 1110 0011. to select slaves 0 and 1 and exclude slave 2 use address 1110 0100, since it is necessary to make bit 2 = 1 to exclude slave 2. the broadcast address for each slave is created by taking the logical or of saddr and saden. zeros in this result are treated as dont cares. in most cases, interpreting the dont-cares as ones, the broadcast address will be ffh. upon reset saddr and saden are loaded with 0s. this produces a given address of all dont cares as well as a broadcast saddr = 1100 0000 saden = 1111 1101 given = 1100 00x0 --------------------------------------------------- - saddr = 1100 0000 saden = 1111 1110 given = 1100 000x --------------------------------------------------- - saddr = 1100 0000 saden = 1111 1001 given = 1100 0xx0 --------------------------------------------------- - saddr = 1110 0000 saden = 1111 1010 given = 1110 0x0x --------------------------------------------------- - saddr = 1100 0000 saden = 1111 1100 given = 1100 00xx --------------------------------------------------- -
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 41 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi address of all dont cares. this effectively disables the automatic addressing mode and allows the microcontroller to use standard uart drivers which do not make use of this feature. 6.7 serial peripheral interface (spi) 6.7.1 spi features ? master or slave operation ? 10 mhz bit frequency (max) ? lsb ?rst or msb ?rst data transfer ? four programmable bit rates ? end of transmission (spif) ? write-collision ?ag protection (wcol) ? wake-up from idle mode (slave mode only) 6.7.2 spi description the serial peripheral interface allows high-speed synchronous data transfer between the p89cv51rb2/rc2/rd2 and peripheral devices or between several p89cv51rb2/rc2/rd2 devices. figure 16 shows the correspondence between master and slave spi devices. the spiclk pin is the clock output and input for the master and slave modes, respectively. the spi clock generator will start following a write to the master devices spi data register. the written data is then shifted out of the mosi pin of the master device into the mosi pin of the slave device. following a complete transmission of one byte of data, the spi clock generator is stopped and the spi interrupt flag (spif) is set. an spi interrupt request will be generated if the spi interrupt enable bit (spie) and the spi interrupt enable bit, es, are both set. an external master drives the slave select input pin ( ss) low to select the spi module as a slave. if ss has not been driven low, then the slave spi unit is not active and the mosi pin can also be used as an input port pin. cpha and cpol control the phase and polarity of the spi clock (sck). figure 17 and figure 18 show the four possible combinations of these two bits.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 42 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 16. spi master-slave interconnection 002aaa528 8-bit shift register msb master lsb spi clock generator miso miso mosi mosi sck sck ss ss 8-bit shift register msb slave lsb v ss v dd table 27. spcr - spi control register (address d5h) bit allocation reset source(s): any reset; reset value: 0000 0000b. bit 7 6 5 4 3 2 1 0 symbol spie spen dord mstr cpol cpha spr1 spr0 table 28. spcr - spi control register (address d5h) bit description bit symbol description 7 spie spi interrupt enable. if both spie = 1 and es = 1, spi interrupts are enabled. 6 spen spi enable bit. when set enables spi. 5 dord data transmission order. 0 = msb ?rst; 1 = lsb ?rst in data transmission. 4 mstr master/slave select. 1 = master mode, 0 = slave mode. 3 cpol clock polarity. 1 = spiclk is high when idle (active low), 0 = spiclk is low when idle (active high). 2 cpha clock phase control bit. 1 = shift-triggered on the trailing edge of the clock; 0 = shift-triggered on the leading edge of the clock. 1 spr1 spi clock rate select bit 1. along with spr0 controls the spiclk rate of the device when a master. spr1 and spr0 have no effect on the slave; see t ab le 29 . 0 spr0 spi clock rate select bit 0. along with spr1 controls the spiclk rate of the device when a master. spr1 and spr0 have no effect on the slave; see t ab le 29 . table 29. spcr - spi control register (address d5h) clock rate selection spr1 spr0 spiclk = f osc divided by 6-clock mode 12-clock mode 002 4 018 16 1 0 32 64 1 1 64 128
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 43 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.8 watchdog timer the wdt is intended as a recovery method in situations where the cpu may be subjected to software upset. the wdt consists of a 14-bit counter and the watchdog timer reset (wdtrst) sfr. the wdt is disabled at reset. to enable the wdt, the user must write 01eh and 0e1h, in sequence, to the wdtrst sfr. when the wdt is enabled, it will increment every machine cycle while the oscillator is running. there is no table 30. spsr - spi status register (address aah) bit allocation reset source(s): any reset; reset value: 0000 0000b. bit 7 6 5 4 3 2 1 0 symbol spif wcol - - - - - - table 31. spsr - spi status register (address aah) bit description bit symbol description 7 spif spi interrupt ?ag. upon completion of data transfer, this bit is set to 1. if spie = 1 and es = 1, an interrupt is then generated. this bit is cleared by software. 6 wcol write collision ?ag. set if the spi data register is written to during data transfer. this bit is cleared by software. 5 to 0 - reserved for future use. should be set to 0 by user programs. fig 17. spi transfer format with cpha = 0 fig 18. spi transfer format with cpha = 1 002aaa529 sck cycle # (for reference) sck (cpol = 0) sck (cpol = 1) mosi (from master) miso (from slave) ss (to slave) 12345678 msb 654321lsb msb 654321lsb 002aaa530 msb sck cycle # (for reference) sck (cpol = 0) sck (cpol = 1) mosi (from master) miso (from slave) ss (to slave) 6 12345678 5 msb654321 lsb 4 3 2 1 lsb
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 44 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi way to disable the wdt, except through a reset (either a hardware reset or a wdt over?ow reset). when the wdt over?ows, it will drive an output reset high pulse at the rst pin. when the wdt is enabled (and thus running) the user needs to reset it by writing 01eh and 0e1h, in sequence, to the wdtrst sfr to avoid wdt over?ow. the 14-bit counter reaches over?ow when it reaches 16383 (3fffh) and this will reset the device. the wdts counter cannot be read or written. when the wdt over?ows it will generate an output pulse at the rst pin with a duration of 98 oscillator periods in 6-clock mode or 196 oscillator periods in 12-clock mode. 6.9 pca the pca includes a special 16-bit timer that has ?ve 16-bit capture/compare modules associated with it. each of the modules can be programmed to operate in one of four modes: rising and/or falling edge capture, software timer, high-speed output, or pulse-width modulator. each module has a pin associated with it: module 0 is connected to cex0, module 1 to cex1, etc. registers ch and cl contain the current value of the free-running up-counting 16-bit pca timer. the pca timer is a common time base for all ?ve modules and can be programmed to run at: 1 6 the oscillator frequency, 1 2 the oscillator frequency, the timer 0 over?ow, or the input on the eci pin (p1[2]). the timer count source is determined from the cps1 and cps0 bits in the cmod sfr; see t ab le 32 and t ab le 33 . in the cmod sfr there are three additional bits associated with the pca. they are cidl which allows the pca to stop during idle mode, wdte which enables or disables the watchdog function on module 4, and ecf which when set causes an interrupt and the pca over?ow ?ag cf (in the ccon sfr) to be set when the pca timer over?ows. the watchdog timer function is implemented in module 4 of pca. the ccon sfr contains the run control bit for the pca (cr) and the ?ags for the pca timer (cf) and each module (ccf[4:0]). to run the pca the cr bit (ccon.6) must be set by software. the pca is shut off by clearing this bit. the cf bit (ccon.7) is set when the pca counter over?ows and an interrupt will be generated if the ecf bit in the cmod fig 19. pca module0 pca timer/counter p1[3]/cex0 module1 p1[4]/cex1 module2 p1[5]/cex2 module3 p1[6]/cex3 module4 p1[7]/cex4 time base for pca modules module functions: - 16-bit capture - 16-bit timer - 16-bit high speed output - 8-bit pwm - watchdog timer (module 4 only) 16 bits 16 bits 002aab913
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 45 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi register is set. the cf bit can only be cleared by software. bits 0 through 4 of the ccon register are the ?ags for the modules (bit 0 for module 0, bit 1 for module 1, etc.) and are set by hardware when either a match or a capture occurs. these ?ags can only be cleared by software. all the modules share one interrupt vector. the pca interrupt system is shown in figure 20 . each module in the pca has a special function register associated with it. these registers are: ccapm0 for module 0, ccapm1 for module 1, etc. the registers contain the bits that control the mode that each module will operate in. the eccf bit (from ccapmn.0 where n = 0, 1, 2, 3, or 4 depending on the module) enables the ccfn ?ag in the ccon sfr to generate an interrupt when a match or compare occurs in the associated module; see figure 20 . pwm (ccapmn.1) enables the pwm mode. the tog bit (ccapmn.2) when set causes the cex output associated with the module to toggle when there is a match between the pca counter and the modules capture/compare register. the match bit mat (ccapmn.3) when set will cause the ccfn bit in the ccon register to be set when there is a match between the pca counter and the modules capture/compare register. the next two bits capn (ccapmn.4) and capp (ccapmn.5) determine the edge that a capture input will be active on. the capn bit enables the negative edge, and the capp bit enables the positive edge. if both bits are set both edges will be enabled and a capture will occur for either transition. the last bit in the register ecom (ccapmn.6) when set enables the comparator function. there are two additional registers associated with each of the pca modules. they are ccapnh and ccapnl and these are the registers that store the 16-bit count when a capture occurs or a compare should occur. when a module is used in the pwm mode, these registers are used to control the duty cycle of the output.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 46 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 20. pca interrupt system 002aaa533 pca timer/counter module0 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 module1 module2 module3 module4 ecf eccfn ie.6 ec ie.7 ea ccapmn.0 cmod.0 ccon (d8h) to interrupt priority decoder table 32. cmod - pca counter mode register (address d9h) bit allocation not bit addressable; reset value: 00h. bit 7 6 5 4 3 2 1 0 symbol cidl wdte - - - cps1 cps0 ecf table 33. cmod - pca counter mode register (address d9h) bit description bit symbol description 7 cidl counter idle control. cidl = 0 programs the pca counter to continue functioning during idle mode; cidl = 1 programs it to be gated off during idle mode. 6 wdte watchdog timer enable. wdte = 0 disables watchdog timer function on module 4; wdte = 1 enables it. 5 to 3 - reserved for future use. should be set to 0 by user programs. 2 to 1 cps1, cps0 pca count pulse select; see t ab le 34 . 0 ecf pca enable counter over?ow interrupt flag. ecf = 1 enables cf bit in ccon to generate an interrupt; ecf = 0 disables that function. table 34. cmod - pca counter mode register (address d9h) count pulse select cps1 cps0 select pca input 0 0 0 internal clock, f osc /6
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 47 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 0 1 1 internal clock, f osc /6 1 0 2 timer 0 over?ow 1 1 3 external clock at pin p1[2]/eci (maximum rate = f osc /4) table 35. ccon - pca counter control register (address d8h) bit allocation bit addressable; reset value: 00h. bit 7 6 5 4 3 2 1 0 symbol cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 table 36. ccon - pca counter control register (address d8h) bit description bit symbol description 7 cf pca counter over?ow flag. set by hardware when the counter rolls over. cf ?ags an interrupt if bit ecf in cmod is set. cf may be set by either hardware or software but can only be cleared by software. 6 cr pca counter run control. set by software to turn the pca counter on. must be cleared by software to turn the pca counter off. 5 - reserved for future use. should be set to 0 by user programs. 4 ccf4 pca module 4 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 3 ccf3 pca module 3 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 2 ccf2 pca module 2 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 1 ccf1 pca module 1 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 0 ccf0 pca module 0 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. table 37. ccapmn - pca modules compare/capture register (address ccapm0 dah, ccapm1 dbh, ccapm2 dch, ccapm3 ddh, ccapm4 deh) bit allocation not bit addressable; reset value: 00h. bit 7 6 5 4 3 2 1 0 symbol - ecomn cappn capnn matn togn pwmn eccfn table 38. ccapmn - pca modules compare/capture register (address ccapm0 dah, ccapm1 dbh, ccapm2 dch, ccapm3 ddh, ccapm4 deh) bit description bit symbol description 7 - reserved for future use. should be set to 0 by user programs. 6 ecomn enable comparator. ecomn = 1 enables the comparator function. 5 cappn capture positive, cappn = 1 enables positive edge capture. 4 capnn capture negative, capnn = 1 enables negative edge capture. 3 matn match. when matn = 1 a match of the pca counter with this modules compare/capture register causes the ccfn bit in ccon to be set, ?agging an interrupt. table 34. cmod - pca counter mode register (address d9h) count pulse select continued cps1 cps0 select pca input
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 48 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.9.1 pca capture mode to use one of the pca modules in the capture mode ( figure 21 ), either one or both of the ccapm bits capn and capp for that module must be set. the external cex input for the module (on port 1) is sampled for a transition. when a valid transition occurs, the pca hardware loads the value of the pca counter registers (ch and cl) into the modules capture registers (ccapnl and ccapnh). 2 togn toggle. when togn = 1, a match of the pca counter with this modules compare/capture register causes the cexn pin to toggle. 1 pwmn pulse width modulation mode. pwmn = 1 enables the cexn pin to be used as a pulse-width modulated output. 0 eccfn enable ccf interrupt. enables compare/capture ?ag ccfn in the ccon register to generate an interrupt. table 38. ccapmn - pca modules compare/capture register (address ccapm0 dah, ccapm1 dbh, ccapm2 dch, ccapm3 ddh, ccapm4 deh) bit description bit symbol description table 39. pca module modes (ccapmn register) ecomn cappn capnn matn togn pwmn eccfn module function 0 0 0 0 0 0 0 no operation x 1 0 0 0 0 x 16-bit capture by a positive-edge trigger on cexn x 0 1 0 0 0 x 16-bit capture by a negative-edge trigger on cexn x 1 1 0 0 0 x 16-bit capture by any transition on cexn 1 0 0 1 0 0 x 16-bit software timer 1 0 0 1 1 0 x 16-bit high-speed output 1 0 0 0 0 1 0 8-bit pwm 1 0 0 1 x 0 x watchdog timer
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 49 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi if the ccfn bit for the module in the ccon sfr and the eccfn bit in the ccapmn sfr are set then an interrupt will be generated. 6.9.2 16-bit software timer mode the pca modules can be used as software timers ( figure 22 ) by setting both the ecom and mat bits in the modules ccapmn register. the pca timer will be compared to the modules capture registers and when a match occurs an interrupt will occur if the ccfn (ccon sfr) and the eccfn (ccapmn sfr) bits for the module are both set. fig 21. pca capture mode 002aaa538 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 ccon (d8h) pca interrupt pca timer/counter - ecomn 0 000 cappn capnn matn togn pwmn eccfn ccapmn, n = 0 to 4 (dah to deh) ch cl ccapnh ccapnl capture (to ccfn) cexn
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 50 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.9.3 high-speed output mode in this mode ( figure 23 ) the cex output (on port 1) associated with the pca module will toggle each time a match occurs between the pca counter and the modules capture registers. to activate this mode the tog, mat, and ecom bits in the modules ccapmn sfr must be set. fig 22. pca compare mode 002aaa539 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 ccon (d8h) pca interrupt - ecomn 00 100 cappn capnn matn togn pwmn eccfn ccapmn, n = 0 to 4 (dah to deh) 16-bit comparator pca timer/counter ch cl match (to ccfn) ccapnh ccapnl enable write to ccapnh write to ccapnl reset 01
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 51 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.9.4 pulse width modulator mode all of the pca modules can be used as pwm outputs ( figure 24 ). output frequency depends on the source for the pca timer. all of the modules will have the same output frequency because they all share only one pca timer. the duty cycle of each module is independently variable using the modules capture register ccapnl. when the value of the pca cl sfr is less than the value in the fig 23. pca high-speed output mode 002aaa540 toggle cexn cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 ccon (d8h) pca interrupt - ecomn 00 100 cappn capnn matn togn pwmn eccfn ccapmn, n = 0 to 4 (dah to deh) 16-bit comparator pca timer/counter ch cl match (to ccfn) ccapnh ccapnl enable write to ccapnh write to ccapnl reset 01 fig 24. pca pwm mode 002aaa541 - ecomn 0 1 0 001 1 cappn capnn matn togn pwmn eccfn ccapmn, n = 0 to 4 (dah to deh) ccapnl 8-bit comparator pca timer/counter ccapnh cl enable cexn cl < ccapnl cl 3 ccapnl 0 1
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 52 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi modules ccapnl sfr, the output will be low; when it is equal to, or greater, the output will be high. when cl over?ows from ffh to 00h, ccapnl is reloaded with the value in ccapnh. this allows the pwm to be updated without glitches. the pwm and ecom bits in the modules ccapmn register must be set to enable pwm mode. 6.9.5 pca watchdog timer an on-board watchdog timer is available with the pca to improve the reliability of the system without increasing chip count. watchdog timers are useful for systems that are susceptible to noise, power glitches, or electrostatic discharge. module 4 is the only pca module that can be programmed as a watchdog. however, this module can still be used for other modes if the watchdog is not needed. figure 24 shows a diagram of how the watchdog works. the user pre-loads a 16-bit value in the compare registers. just like the other compare modes, this 16-bit value is compared to the pca timer value. if a match is allowed to occur, an internal reset will be generated. this will not cause the rst pin to be driven high. users software then must periodically change (ccap4h, ccap4l) to keep a match from occurring with the pca timer (ch, cl). this code is given in the subroutine watchdog shown below. in order to hold off the reset, the user has three options: ? periodically change the compare value so it will never match the pca timer. ? periodically change the pca timer value so it will never match the compare values. ? disable the watchdog by clearing the wdte bit before a match occurs and then re-enable it. the ?rst two options are more reliable because the watchdog timer is never disabled as in the third option. if the program counter ever reaches an undesired value, a match will eventually occur and cause an internal reset. the second option is also not recommended if other pca modules are being used. remember that the pca timer is the time base for all modules; changing the time base for other modules is not recommended. thus, in most applications the ?rst option is best. ;call the following watchdog subroutine periodically. clr ea ;hold off interrupts mov ccap4l,#00 ;next compare value is within 255 counts of current pca timer value mov ccap4h,ch setb ea ;re-enable interrupts ret do not use this routine as part of an interrupt service routine, because if the program counter would enter an in?nite loop, still interrupts will be serviced and the watchdog will continually keep getting reset. because this would defeat the purpose of the watchdog, it is recommended that this subroutine is called from the main program within 2 16 pca timer counts.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 53 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.10 security bits the security bits protect against software piracy and prevent the contents of the ?ash from being read by unauthorized parties in parallel programmer mode and isp mode. since the end application might need to erase pages and read from the code memory, the security bits have no effect in iap mode. however, the security bits programmed/erased state may be read using iap function calls allowing the end-user code to limit access, if desired. the security bits and their effects are shown in t ab le 40 . note: on this device, movc instructions executed from external code memory are prevented from fetching code bytes from internal code memory. 6.11 interrupt priority and polling sequence the device supports eight interrupt sources under a four-level priority scheme. t ab le 41 summarizes the polling sequence of the supported interrupts. note that the spi serial interface and the uart share the same interrupt vector; see figure 25 . table 40. security bit functions security bit description 1 write protect. when programmed, prohibits further erasing or programming, except to program other security bits or a chip erase. 2 read protect. when programmed, inhibits reading of user code memory. 3 external execution inhibit. when programmed, prevents any execution of instructions from external code memory. table 41. interrupt polling sequence description interrupt ?ag vector address interrupt enable interrupt priority service priority wake-up power-down external interrupt 0 ie0 0003h ex0 px0/px0h 1 (highest) yes t0 tf0 000bh et0 pt0/pt0h 2 no external interrupt 1 ie1 0013h ex1 px1/px1h 3 yes t1 tf1 001bh et1 pt1/pt1h 4 no uart ti/ri 0023h es ps/psh 5 no spi spif 0023h es ps/psh 5 no pca cf/ccfn 0033h ec ppc/ppch 7 no t2 tf2, exf2 003bh et2 pt2/pt2h 6 no
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 54 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 25. interrupt structure 002aac965 highest priority interrupt interrupt polling sequence int0# ie and iea registers ip/iph/ipa/ipah registers individual enables global disable ie0 0 1 it0 lowest priority interrupt tf0 int1# tf1 cf ecf ccfn eccfn ri ti tf2 exf2 ie1 0 1 it1 spif spie table 42. ie - interrupt enable register 0 (address a8h) bit allocation bit addressable; reset value: 00h. bit 7 6 5 4 3 2 1 0 symbol ea ec et2 es et1 ex1 et0 ex0 table 43. ie - interrupt enable register 0 (address a8h) bit description bit symbol description 7 ea interrupt enable. ea = 1: interrupt(s) can be serviced; ea = 0: interrupt servicing disabled. 6 ec pca interrupt enable. 5 et2 timer 2 interrupt enable.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 55 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 4 es serial port interrupt enable. 3 et1 timer 1 over?ow interrupt enable. 2 ex1 external interrupt 1 enable. 1 et0 timer 0 over?ow interrupt enable. 0 ex0 external interrupt 0 enable. table 44. ip - interrupt priority low register (address b8h) bit allocation bit addressable; reset value: 00h. bit 7 6 5 4 3 2 1 0 symbol - ppc pt2 ps pt1 px1 pt0 px0 table 45. ip - interrupt priority low register (address b8h) bit description bit symbol description 7 - reserved for future use. should be set to 0 by user programs. 6 ppc pca interrupt priority low. 5 pt2 timer 2 interrupt priority low. 4 ps serial port interrupt priority low. 3 pt1 timer 1 interrupt priority low. 2 px1 external interrupt 1 priority low. 1 pt0 timer 0 interrupt priority low. 0 px0 external interrupt 0 priority low. table 46. iph - interrupt priority high register (address b7h) bit allocation not bit addressable; reset value: 00h. bit 7 6 5 4 3 2 1 0 symbol - ppch pt2h psh pt1h px1h pt0h px0h table 47. iph - interrupt priority high register (address b7h) bit description bit symbol description 7 - reserved for future use. should be set to 0 by user programs. 6 ppch pca interrupt priority high. 5 pt2h timer 2 interrupt priority high. 4 psh serial port interrupt priority high. 3 pt1h timer 1 interrupt priority high. 2 px1h external interrupt 1 priority high. 1 pt0h timer 0 interrupt priority high. 0 px0h external interrupt 0 priority high. table 43. ie - interrupt enable register 0 (address a8h) bit description continued bit symbol description
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 56 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.12 power-saving modes the device provides two power-saving modes of operation for applications where power consumption is critical. the two modes are idle and power-down; see t ab le 48 . 6.12.1 idle mode idle mode is entered by setting the idl bit in the pcon register. in idle mode, the program counter is stopped. the system clock continues to run and all interrupts and peripherals remain active. the on-chip ram and the special function registers hold their data during this mode. the device exits idle mode through either a system interrupt or a hardware reset. when exiting idle mode via system interrupt, the start of the interrupt clears the idl bit and exits idle mode. after exiting the interrupt service routine (isr), the interrupted program resumes execution at the instruction immediately following the instruction which invoked the idle mode. a hardware reset starts the device similar to a power-on reset. 6.12.2 power-down mode the power-down mode is entered by setting the pd bit in the pcon register. in the power-down mode, the clock is stopped and external interrupts are active for level-sensitive interrupts only. sram contents are retained during power-down, the minimum v dd level is 4.5 v. the device exits power-down mode through either an enabled external level-sensitive interrupt or a hardware reset. the start of the interrupt clears the pd bit and exits power-down. holding an external interrupt pin low restarts the oscillator, the signal must hold low at least 1024 clock cycles before bringing back high to complete the exit. when the interrupt signal is restored to logic v ih , the interrupt service routine program execution resumes at the instruction immediately following the instruction which invoked power-down mode. a hardware reset starts the device similar to a power-on reset. to exit properly out of power-down, the reset or external interrupt should not be executed before the v dd line is restored to its normal operating voltage. be sure to hold v dd voltage long enough at its normal operating level for the oscillator to restart and stabilize (normally less than 10 ms). table 48. power-saving modes mode initiated by state of mcu exited by idle software (set idl bit in pcon) mov pcon, #01h clk is running. interrupts, serial port and timers/counters are active. program counter is stopped. ale and psen signals at a high-state during idle. all registers remain unchanged. enabled interrupt or hardware reset. start of interrupt clears idl bit and exits idle mode, after the isr reti instruction, program resumes execution beginning at the instruction following the one that invoked idle mode. a hardware reset restarts the device similar to a power-on reset. power-down software (set pd bit in pcon) mov pcon, #02h clk is stopped. on-chip sram and sfr data is maintained. ale and psen signals at a low-state during power-down. external interrupts are only active for level-sensitive interrupts, if enabled. enabled external level-sensitive interrupt or hardware reset. start of interrupt clears pd bit and exits power-down mode, after the isr reti instruction program resumes execution beginning at the instruction following the one that invoked power-down mode. a hardware reset restarts the device similar to a power-on reset.
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 57 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.13 system clock and clock options 6.13.1 clock input options and recommended capacitor values for oscillator shown in figure 26 and figure 27 are the input and output of an internal inverting ampli?er (xtal1, xtal2), which can be con?gured for use as an on-chip oscillator. when driving the device from an external clock source, xtal2 should be left disconnected and xtal1 should be driven. at start-up, the external oscillator may encounter a higher capacitive load at xtal1 due to interaction between the ampli?er and its feedback capacitance. however, the capacitance will not exceed 15 pf once the external signal meets the v il and v ih speci?cations. resonator manufacturer, supply voltage, and other factors may cause circuit performance to differ from one application to another. c 1 and c 2 should be adjusted appropriately for each design. t ab le 49 shows the typical values for c 1 and c 2 versus resonator type for various frequencies. table 49. recommended values for c 1 and c 2 by crystal type resonator c 1 =c 2 quartz 20 pf to 30 pf ceramic 40 pf to 50 pf fig 26. oscillator characteristics (using the on-chip oscillator) fig 27. oscillator characteristics (external clock drive) 002aaa545 xtal2 xtal1 v ss c 1 c 2 002aaa546 xtal2 n.c. xtal1 external oscillator signal v ss
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 58 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 6.13.1.1 clock control register (ckcon) by default, the device runs at twelve clock cycles per machine cycle (12-clock mode). the device may be run at 6 clock cycles per machine cycle (6-clock mode) by programming of either a non-volatile bit (fx2) or an sfr bit (x2); see t ab le 52 cloc k modes . if the fx2 non-volatile bit is programmed, the device will run in 6-clock mode and the x2 sfr bit has no effect. if the fx2 bit is erased, then the clock mode is controlled by the x2 sfr bit. table 50. ckcon - clock control register (address 8fh) bit allocation not bit addressable; reset value 00h. bit 7 6 5 4 3 2 1 0 symbol spix2 wdx2 pcax2 six2 t2x2 t1x2 t0x2 x2 table 51. ckcon - clock control register (address 8fh) bit description bit symbol description 7 spix2 spi clock; 0 = 6 clock cycles for each spi clock cycle; 1 = 12 clock cycles 6 wdx2 watchdog clock; 0 = 6 clock cycles for each wdt clock cycle; 1 = 12 clock cycles 5 pcax2 pca clock; 0 = 6 clock cycles for each pca clock cycle; 1 = 12 clock cycles 4 six2 uart clock; 0 = 6 clock cycles for each uart clock cycle; 1 = 12 clock cycles 3 t2x2 timer 2 clock; 0 = 6 clock cycles for each timer 2 clock cycle; 1 = 12 clock cycles 2 t1x2 timer 1 clock; 0 = 6 clock cycles for each timer 1 clock cycle; 1 = 12 clock cycles 1 t0x2 timer 0 clock; 0 = 6 clock cycles for each timer 0 clock cycle; 1 = 12 clock cycles 0 x2 cpu clock; 0 = 12 clock cycles for each machine cycle; 1 = 6 clock cycles table 52. clock modes fx2 clock mode bit x2 bit cpu clock mode peripheral clock mode bit (e.g. t0x2) mode erased 0 12-clock (default) x 12-clock (default) 1 6-clock 0 6-clock 1 12-clock programmed x 6-clock 0 6-clock 1 12-clock
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 59 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 7. limiting values 8. static characteristics table 53. limiting values in accordance with the absolute maximum rating system (iec 60134). parameters are valid over operating temperature range unless otherwise speci?ed; all voltages are with respect to v ss unless otherwise noted. symbol parameter conditions min max unit t amb(bias) bias ambient temperature - 55 +125 c t stg storage temperature - 65 +150 c v i input voltage on ea pin to v ss - 0.5 +14 v v n voltage on any other pin except v ss ; with respect to v dd - 0.5 v dd + 0.5 v i ol(i/o) low-level output current per input/output pin -15ma p tot(pack) total power dissipation (per package) based on package heat transfer, not device power consumption - 1.5 w table 54. static characteristics t amb = - 40 c to +85 c; v dd = 4.5 v to 5.5 v; v ss =0v. symbol parameter conditions min typ max unit n endu(?) endurance of ?ash memory jedec standard a117 [1] 10000 - - cycles t ret(?) ?ash memory retention time jedec standard a103 [1] 100 - - years i latch i/o latch-up current jedec standard 78 [1] 100 + i dd -- ma v th(hl) high-low threshold voltage - 0.5 - +0.2v dd - 0.1 v v th(lh) low-high threshold voltage except xtal1, rst 0.2v dd + 0.9 - v dd + 0.5 v v ol low-level output voltage v dd = 4.5 v; except psen, ale [2] [3] [4] i ol = 1.6 ma - - 0.4 v v dd = 4.5 v; ale, psen i ol = 3.2 ma - - 0.45 v v oh high-level output voltage v dd = 4.5 v; ports 1, 2, 3, 4 [5] i oh = - 30 m av dd - 0.7 - - v v dd = 4.5 v; port 0 in external bus mode, ale, psen i oh = - 3.2 ma v dd - 0.7 - - v i il low-level input current v i = 0.4 v; ports 1, 2, 3, 4 - 1- - 75 m a i thl high-low transition current v i = 2 v; ports 1, 2, 3, 4 [6] -- - 650 m a i li input leakage current 0.45 v < v i p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 60 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi [1] this parameter is measured only for initial quali?cation and after a design or process change that could affect this paramet er. [2] under steady state (non-transient) conditions, i ol must be externally limited as follows: a) maximum i ol per 8-bit port: 26 ma b) maximum i ol total for all outputs: 71 ma c) if i ol exceeds the test condition, v oh may exceed the related speci?cation. pins are not guaranteed to sink current greater than the listed test conditions. [3] capacitive loading on ports 0 and 2 may cause spurious noise to be superimposed on the v ol of ale and ports 1 and 3. the noise is due to external bus capacitance discharging into the port 0 and 2 pins when the pins make 1-to-0 transitions during bus operatio ns. in the worst cases (capacitive loading > 100 pf), the noise pulse on the ale pin may exceed 0.8 v. in such cases, it may be desirable to qualify ale with a schmitt trigger, or use an address latch with a schmitt trigger strobe input. [4] load capacitance for port 0, ale and psen = 100 pf, load capacitance for all other outputs = 80 pf. [5] capacitive loading on ports 0 and 2 may cause the v oh on ale and psen to momentarily fall below the v dd - 0.7 v speci?cation when the address bits are stabilizing. [6] pins of ports 1, 2 and 3 source a transition current when they are being externally driven from 1 to 0. the transition curre nt reaches its maximum value when v i is approximately 2 v. [7] pin capacitance is characterized but not tested. capacitance on pin ea = 25 pf (max.). r pd pull-down resistance on pin rst 40 - 225 k w c iss input capacitance 1 mhz; t amb =25 c; v i =0v [7] - - 15 pf i dd(oper) operating supply current f osc = 12 mhz - - 11.5 ma f osc = 40 mhz - - 50 ma programming and erase mode - - 70 ma i dd(idle) idle mode supply current f osc = 12 mhz - - 8.5 ma f osc = 40 mhz - - 42 ma i dd(pd) power-down mode supply current minimum v dd = 4.5 v - - 90 m a table 54. static characteristics continued t amb = - 40 c to +85 c; v dd = 4.5 v to 5.5 v; v ss =0v. symbol parameter conditions min typ max unit
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 61 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi (1) maximum active i dd (2) maximum idle i dd (3) typical active i dd (4) typical idle i dd fig 28. i dd as a function of frequency internal clock frequency (mhz) 0 40 30 20 10 002aaa813 20 30 10 40 50 i dd (ma) 0 (1) (2) (3) (4)
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 62 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 9. dynamic characteristics [1] t cy(clk) = 1 / f osc . [2] calculated values are for 6-clock mode only. table 55. dynamic characteristics over operating conditions: load capacitance for port 0, ale, and psen = 100 pf; load capacitance for all other outputs = 80 pf. t amb = - 40 c to +85 c; v dd = 4.5 v to 5.5 v; v ss =0v. [1] [2] symbol parameter conditions min typ max unit f osc oscillator frequency 12-clock mode 0 - 40 mhz 6-clock mode 0 - 20 mhz iap 0.25 - 40 mhz t lhll ale pulse width 2t cy(clk) - 15 - - ns t avll address valid to ale low time t cy(clk) - 15 - - ns t llax address hold after ale low time t cy(clk) - 15 - - ns t lliv ale low to valid instruction in time - - 4t cy(clk) - 45 ns t llpl ale low to psen low time t cy(clk) - 15 - - ns t plph psen pulse width 3t cy(clk) - 15 - - ns t pliv psen low to valid instruction in time --3t cy(clk) - 50 ns t pxix input instruction hold after psen time 0 - - ns t pxiz input instruction ?oat after psen time - - t cy(clk) - 15 ns t pxav psen to address valid time t cy(clk) - 8- - ns t aviv address to valid instruction in time - - 5t cy(clk) - 60 ns t plaz psen low to address ?oat time - - 10 ns t rlrh rd low pulse width 6t cy(clk) - 30 - - ns t wlwh wr low pulse width 6t cy(clk) - 30 - - ns t rldv rd low to valid data in time - - 5t cy(clk) - 50 ns t rhdx data hold after rd time 0 - - ns t rhdz data ?oat after rd time - - 2t cy(clk) - 12 ns t lldv ale low to valid data in time - - 8t cy(clk) - 50 ns t avdv address to valid data in time - - 9t cy(clk) - 75 ns t llwl ale low to rd or wr low time 3t cy(clk) - 15 - 3t cy(clk) + 15 ns t avwl address to rd or wr low time 4t cy(clk) - 30 - - ns t whqx data hold after wr time t cy(clk) - 20 - - ns t qvwh data output valid to wr high time 7t cy(clk) - 50 - - ns t rlaz rd low to address ?oat time - - 0 ns t whlh rd or wr high to ale high time t cy(clk) - 15 - t cy(clk) + 15 ns
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 63 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 9.1 explanation of symbols each timing symbol used in figure 29 to figure 33 has 5 characters. the ?rst character is always a t (stands for time). the other characters, depending on their positions, stand for the name of a signal or the logical status of that signal. the following is a list of all the characters and what they stand for. a address c clock d input data h logic level high i instruction (program memory contents) l logic level low or ale p psen q output data r rd signal t cycle time v valid w wr signal x no longer a valid logic level z high impedance (?oat) example: t avll = address valid to ale low time t llpl = ale low to psen low time fig 29. external program memory read cycle 002aaa548 port 2 psen ale a0 to a7 t llax t plaz t pxiz t llpl t aviv t avll t lliv t pliv t plph instr in a8 to a15 a8 to a15 a0 to a7 port 0 t pxix t pxav t lhll
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 64 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 30. external data memory read cycle ale psen port 0 port 2 rd a0 to a7 from ri to dpl data in a0 to a7 from pcl instr in p2.0 to p2.7 or a8 to a15 from dph a0 to a15 from pch t lldv 002aaa549 t whlh t avdv t llwl t avll t avwl t rlrh t rldv t llax t rhdz t rhdx t rlaz fig 31. external data memory write cycle 002aaa550 port 2 port 0 wr psen ale t lhll p2[7:0] or a8 to a15 from dph a0 to a7 from ri or dpl data out instr in t avll t avwl t llwl t llax t wlwh t qvwh t whqx t whlh a8 to a15 from pch a0 to a7 from pcl
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 65 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi table 56. external clock drive symbol parameter oscillator unit 40 mhz variable min max min max f osc oscillator frequency - - 0 40 mhz t cy(clk) clock cycle time 25 - - - ns t chcx clock high time 8.75 - 0.35t cy(clk) 0.65t cy(clk) ns t clcx clock low time 8.75 - 0.35t cy(clk) 0.65t cy(clk) ns t clch clock rise time - 10 - - ns t chcl clock fall time - 10 - - ns fig 32. external clock timing (with an amplitude of at least v i(rms) = 200 mv) t chcl t clcx t chcx t cy(clk) t clch 002aaa907 table 57. serial port timing symbol parameter oscillator unit 40 mhz variable min max min max t xlxl serial port clock cycle time 0.3 - 12t cy(clk) - m s t qvxh output data set-up to clock rising edge time 117 - 10t cy(clk) - 133 - ns t xhqx output data hold after clock rising edge time 0- 2t cy(clk) - 50 - ns t xhdx input data hold after clock rising edge time 0- 0 - ns t xhdv input data valid to clock rising edge time - 117 - 10t cy(clk) - 133 ns
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 66 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 33. shift register mode timing waveforms 002aaa552 ale 0 instruction 1 2 3 4 5 6 7 8 01234567 valid valid valid valid valid valid valid valid t xlxl set ti set ri t xhqx t qvxh t xhdv t xhdx clock output data write to sbuf input data clear ri table 58. spi interface timing symbol parameter conditions variable clock f osc =18mhz unit min max min max f spi spi operating frequency 0 t cy(clk) / 4 0 10 mhz t spicyc spi cycle time see figure 34 , 35 , 36 , 37 4t cy(clk) - 222 - ns t spilead spi enable lead time see figure 36 , 37 250 - 250 - ns t spilag spi enable lag time see figure 36 , 37 250 - 250 - ns t spiclkh spiclk high time see figure 34 , 35 , 36 , 37 2t cy(clk) - 111 - ns t spiclkl spiclk low time see figure 34 , 35 , 36 , 37 2t cy(clk) - 111 - ns t spidsu spi data set-up time master or slave; see figure 34 , 35 , 36 , 37 100 - 100 - ns t spidh spi data hold time master or slave; see figure 34 , 35 , 36 , 37 100 - 100 - ns t spia spi access time see figure 36 , 37 0 80 0 80 ns t spidis spi disable time see figure 36 , 37 0 160 - 160 ns t spidv spi enable to output data valid time see figure 34 , 35 , 36 , 37 - 111 - 111 ns t spioh spi output data hold time see figure 34 , 35 , 36 , 37 0-0-ns t spir spi rise time see figure 34 , 35 , 36 , 37 spi outputs (spiclk, mosi, miso) - 100 - 100 ns spi inputs (spiclk, mosi, miso, ss) - 2000 - 2000 ns t spif spi fall time see figure 34 , 35 , 36 , 37 spi outputs (spiclk, mosi, miso) - 100 - 100 ns spi inputs (spiclk, mosi, miso, ss) - 2000 - 2000 ns
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 67 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 34. spi master timing (cpha = 0) t spicyc t spiclkh t spiclkh t spiclkl t spiclkl master lsb/msb out master msb/lsb out t spidh t spidsu t spif t spioh t spidv t spir t spidv t spif t spir t spif t spir ss spiclk (cpol = 0) (output) 002aaa908 spiclk (cpol = 1) (output) miso (input) mosi (output) lsb/msb in msb/lsb in fig 35. spi master timing (cpha = 1) t spicyc t spiclkl t spiclkl t spiclkh t spiclkh master lsb/msb out master msb/lsb out t spidh t spidsu t spif t spioh t spidv t spir t spidv t spif t spif t spir t spir ss spiclk (cpol = 0) (output) 002aaa909 spiclk (cpol = 1) (output) miso (input) mosi (output) lsb/msb in msb/lsb in
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 68 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 36. spi slave timing (cpha = 0) t spicyc t spiclkh t spiclkh t spiclkl t spiclkl t spilead t spilag t spidsu t spidh t spidh t spidsu t spidsu t spir t spia t spioh t spidis t spir slave msb/lsb out msb/lsb in lsb/msb in slave lsb/msb out t spidv t spioh t spioh t spidv t spir t spir t spif t spif ss spiclk (cpol = 0) (input) 002aaa910 spiclk (cpol = 1) (input) miso (output) mosi (input) not defined fig 37. spi slave timing (cpha = 1) 002aaa911 t spicyc t spiclkh t spiclkh t spiclkl t spilead t spiclkl t spilag t spidsu t spidsu t spidsu t spidh t spidh t spir t spir t spir t spia t spioh t spioh t spioh t spidis slave msb/lsb out not defined msb/lsb in lsb/msb in slave lsb/msb out t spidv t spidv t spidv t spir t spif t spif ss spiclk (cpol = 0) (input) spiclk (cpol = 1) (input) miso (output) mosi (input)
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 69 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 38. test load example all other pins disconnected fig 39. i dd test condition, active mode all other pins disconnected fig 40. i dd test condition, idle mode 002aaa555 to dut to tester c l 002aaa556 v dd v dd v dd p0 ea rst xtal2 (n.c.) clock signal xtal1 v ss i dd v dd 8 dut 002aaa557 v dd v dd v dd p0 ea rst xtal2 (n.c.) clock signal xtal1 v ss i dd 8 dut
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 70 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi all other pins disconnected fig 41. i dd test condition, power-down mode 002aad019 v dd v dd = 4.5 v v dd p0 ea rst xtal2 (n.c.) xtal1 v ss i dd v dd 8 dut
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 71 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 10. package outline fig 42. package outline sot376-1 (tqfp44) unit a max. a 1 a 2 a 3 b p ce (1) eh e ll p z y w v q references outline version european projection issue date iec jedec jeita mm 1.2 0.15 0.05 1.05 0.95 0.25 0.45 0.30 0.18 0.12 10.1 9.9 0.8 12.15 11.85 1.2 0.8 7 0 o o 0.2 0.1 0.2 1 dimensions (mm are the original dimensions) note 1. plastic or metal protrusions of 0.25 mm maximum per side are not included. 0.75 0.45 sot376-1 137e08 ms-026 00-01-19 02-03-14 d (1) (1) (1) 10.1 9.9 h d 12.15 11.85 e z 1.2 0.8 d b p e e b 11 d h b p e h v m b d z d a z e e v m a 1 44 34 33 23 22 12 q a 1 a l p detail x l (a ) 3 a 2 x y c w m w m 0 2.5 5 mm scale tqfp44: plastic thin quad flat package; 44 leads; body 10 x 10 x 1.0 mm sot376-1 pin 1 index
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 72 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi fig 43. package outline sot187-2 (plcc44) unit a a 1 min. a 4 max. b p ey w v b references outline version european projection issue date iec jedec jeita mm 4.57 4.19 0.51 3.05 0.53 0.33 0.021 0.013 16.66 16.51 1.27 17.65 17.40 2.16 45 o 0.18 0.1 0.18 dimensions (mm dimensions are derived from the original inch dimensions) note 1. plastic or metal protrusions of 0.25 mm (0.01 inch) maximum per side are not included. sot187-2 d (1) e (1) 16.66 16.51 h d h e 17.65 17.40 z d (1) max. z e (1) max. 2.16 b 1 0.81 0.66 k 1.22 1.07 0.180 0.165 0.02 0.12 a 3 0.25 0.01 0.656 0.650 0.05 0.695 0.685 0.085 0.007 0.004 0.007 l p 1.44 1.02 0.057 0.040 0.656 0.650 0.695 0.685 e d e e 16.00 14.99 0.63 0.59 16.00 14.99 0.63 0.59 0.085 0.032 0.026 0.048 0.042 29 39 44 1 6 717 28 18 40 detail x (a ) 3 b p w m a 1 a a 4 l p b 1 b k x y e e b d h e e e h v m b d z d a z e e v m a pin 1 index 112e10 ms-018 edr-7319 0 5 10 mm scale 99-12-27 01-11-14 inches plcc44: plastic leaded chip carrier; 44 leads sot187-2 d e
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 73 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 11. abbreviations table 59. abbreviations acronym description ale address latch enable cpu central processing unit dptr data pointer dut device under test eprom erasable programmable read-only memory emi electro-magnetic interference id identi?er iap in-application programming isp in-system programming lsb least signi?cant bit mcu microcontroller unit msb most signi?cant bit pca programmable counter array pch programmable counter high pcl programmable counter low pwm pulse-width modulator ram random access memory rc resistance-capacitance sfr special function register spi serial peripheral interface sram static random access memory uart universal asynchronous receiver/transmitter wdt watchdog timer
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 74 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 12. revision history table 60. revision history document id release date data sheet status change notice supersedes p89cv51rb2_rc2_rd2_3 20090825 product data sheet - p89cv51rb2_rc2_rd2_2 modi?cations: ? t ab le 4 : auxr1, replaced - with enboot. ? t ab le 4 : cmod, replaced c1h with d9h. ? t ab le 8 : replaced - with enboot. ? t ab le 32 : replaced c1h with d9h. ? t ab le 33 : replaced c1h with d9h. ? t ab le 34 : replaced c1h with d9h. p89cv51rb2_rc2_rd2_2 20090422 product data sheet - p89cv51rb2_rc2_rd2_1 modi?cations: ? section 6.2.1: corrected value for extram bit setting. p89cv51rb2_rc2_rd2_1 20071005 product data sheet - -
p89cv51rb2_rc2_rd2_3 ? nxp b.v. 2009. all rights reserved. product data sheet rev. 03 25 august 2009 75 of 76 nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi 13. legal information 13.1 data sheet status [1] please consult the most recently issued document before initiating or completing a design. [2] the term short data sheet is explained in section de?nitions. [3] the product status of device(s) described in this document may have changed since this document was published and may differ in case of multiple dev ices. the latest product status information is available on the internet at url http://www .nxp .com . 13.2 de?nitions draft the document is a draft version only. the content is still under internal review and subject to formal approval, which may result in modi?cations or additions. nxp semiconductors does not give any representations or warranties as to the accuracy or completeness of information included herein and shall have no liability for the consequences of use of such information. short data sheet a short data sheet is an extract from a full data sheet with the same product type number(s) and title. a short data sheet is intended for quick reference only and should not be relied upon to contain detailed and full information. for detailed and full information see the relevant full data sheet, which is available on request via the local nxp semiconductors sales of?ce. in case of any inconsistency or con?ict with the short data sheet, the full data sheet shall prevail. 13.3 disclaimers general information in this document is believed to be accurate and reliable. however, nxp semiconductors does not give any representations or warranties, expressed or implied, as to the accuracy or completeness of such information and shall have no liability for the consequences of use of such information. right to make changes nxp semiconductors reserves the right to make changes to information published in this document, including without limitation speci?cations and product descriptions, at any time and without notice. this document supersedes and replaces all information supplied prior to the publication hereof. suitability for use nxp semiconductors products are not designed, authorized or warranted to be suitable for use in medical, military, aircraft, space or life support equipment, nor in applications where failure or malfunction of an nxp semiconductors product can reasonably be expected to result in personal injury, death or severe property or environmental damage. nxp semiconductors accepts no liability for inclusion and/or use of nxp semiconductors products in such equipment or applications and therefore such inclusion and/or use is at the customers own risk. applications applications that are described herein for any of these products are for illustrative purposes only. nxp semiconductors makes no representation or warranty that such applications will be suitable for the speci?ed use without further testing or modi?cation. limiting values stress above one or more limiting values (as de?ned in the absolute maximum ratings system of iec 60134) may cause permanent damage to the device. limiting values are stress ratings only and operation of the device at these or any other conditions above those given in the characteristics sections of this document is not implied. exposure to limiting values for extended periods may affect device reliability. terms and conditions of sale nxp semiconductors products are sold subject to the general terms and conditions of commercial sale, as published at http://www .nxp .com/pro? le/ter ms , including those pertaining to warranty, intellectual property rights infringement and limitation of liability, unless explicitly otherwise agreed to in writing by nxp semiconductors. in case of any inconsistency or con?ict between information in this document and such terms and conditions, the latter will prevail. no offer to sell or license nothing in this document may be interpreted or construed as an offer to sell products that is open for acceptance or the grant, conveyance or implication of any license under any copyrights, patents or other industrial or intellectual property rights. export control this document as well as the item(s) described herein may be subject to export control regulations. export might require a prior authorization from national authorities. 13.4 trademarks notice: all referenced brands, product names, service names and trademarks are the property of their respective owners. 14. contact information for more information, please visit: http://www .nxp.com for sales of?ce addresses, please send an email to: salesad dresses@nxp.com document status [1] [2] product status [3] de?nition objective [short] data sheet development this document contains data from the objective speci?cation for product development. preliminary [short] data sheet quali?cation this document contains data from the preliminary speci?cation. product [short] data sheet production this document contains the product speci?cation.
nxp semiconductors p89cv51rb2/rc2/rd2 80c51 with 1 kb ram, spi ? nxp b.v. 2009. all rights reserved. for more information, please visit: http://www.nxp.com for sales office addresses, please send an email to: salesaddresses@nxp.com date of release: 25 august 2009 document identifier: p89cv51rb2_rc2_rd2_3 please be aware that important notices concerning this document and the product(s) described herein, have been included in section legal information. 15. contents 1 general description . . . . . . . . . . . . . . . . . . . . . . 1 2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2.1 principal features . . . . . . . . . . . . . . . . . . . . . . . 1 2.2 additional features . . . . . . . . . . . . . . . . . . . . . . 1 2.3 comparison to p89c51rb2/rc2/rd2 devices 2 3 ordering information . . . . . . . . . . . . . . . . . . . . . 2 3.1 ordering options . . . . . . . . . . . . . . . . . . . . . . . . 2 4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5 pinning information . . . . . . . . . . . . . . . . . . . . . . 4 5.1 pinning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 5.2 pin description . . . . . . . . . . . . . . . . . . . . . . . . . 5 6 functional description . . . . . . . . . . . . . . . . . . . 9 6.1 special function registers . . . . . . . . . . . . . . . . . 9 6.2 memory organization . . . . . . . . . . . . . . . . . . . 13 6.2.1 expanded data ram addressing . . . . . . . . . . 13 6.2.2 dual data pointers. . . . . . . . . . . . . . . . . . . . . . 15 6.2.3 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 6.3 flash memory. . . . . . . . . . . . . . . . . . . . . . . . . 17 6.3.1 flash organization . . . . . . . . . . . . . . . . . . . . . 17 6.3.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 6.3.3 boot block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.3.4 power-on reset code execution. . . . . . . . . . . . 18 6.3.5 hardware activation of the bootloader . . . . . . 18 6.3.6 isp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.3.7 using isp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6.3.8 iap method . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 6.4 timers/counters 0 and 1 . . . . . . . . . . . . . . . . . 26 6.4.1 mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 6.4.2 mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 6.4.3 mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 6.4.4 mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 6.5 timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 6.5.1 capture mode . . . . . . . . . . . . . . . . . . . . . . . . . 31 6.5.2 auto-reload mode (up or down counter) . . . . . 32 6.5.3 programmable clock-out . . . . . . . . . . . . . . . . . 34 6.5.4 baud rate generator mode . . . . . . . . . . . . . . . 34 6.5.5 summary of baud rate equations . . . . . . . . . . 35 6.6 uart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.6.1 mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.6.2 mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.6.3 mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.6.4 mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6.6.5 framing error . . . . . . . . . . . . . . . . . . . . . . . . . 37 6.6.6 more about uart mode 1 . . . . . . . . . . . . . . . 38 6.6.7 more about uart modes 2 and 3 . . . . . . . . . 38 6.6.8 multiprocessor communications . . . . . . . . . . . 38 6.6.9 automatic address recognition . . . . . . . . . . . . 39 6.7 serial peripheral interface (spi). . . . . . . . . . . 41 6.7.1 spi features . . . . . . . . . . . . . . . . . . . . . . . . . . 41 6.7.2 spi description . . . . . . . . . . . . . . . . . . . . . . . . 41 6.8 watchdog timer . . . . . . . . . . . . . . . . . . . . . . . 43 6.9 pca . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 6.9.1 pca capture mode. . . . . . . . . . . . . . . . . . . . . 48 6.9.2 16-bit software timer mode. . . . . . . . . . . . . . . 49 6.9.3 high-speed output mode . . . . . . . . . . . . . . . . 50 6.9.4 pulse width modulator mode . . . . . . . . . . . . . 51 6.9.5 pca watchdog timer . . . . . . . . . . . . . . . . . . . 52 6.10 security bits . . . . . . . . . . . . . . . . . . . . . . . . . . 53 6.11 interrupt priority and polling sequence . . . . . . 53 6.12 power-saving modes . . . . . . . . . . . . . . . . . . . 56 6.12.1 idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 6.12.2 power-down mode . . . . . . . . . . . . . . . . . . . . . 56 6.13 system clock and clock options . . . . . . . . . . . 57 6.13.1 clock input options and recommended capacitor values for oscillator . . . . . . . . . . . . . 57 6.13.1.1 clock control register (ckcon) . . . . . . . . . . . 58 7 limiting values . . . . . . . . . . . . . . . . . . . . . . . . 59 8 static characteristics . . . . . . . . . . . . . . . . . . . 59 9 dynamic characteristics . . . . . . . . . . . . . . . . . 62 9.1 explanation of symbols . . . . . . . . . . . . . . . . . 63 10 package outline . . . . . . . . . . . . . . . . . . . . . . . . 71 11 abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . 73 12 revision history . . . . . . . . . . . . . . . . . . . . . . . 74 13 legal information . . . . . . . . . . . . . . . . . . . . . . 75 13.1 data sheet status . . . . . . . . . . . . . . . . . . . . . . 75 13.2 de?nitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 13.3 disclaimers. . . . . . . . . . . . . . . . . . . . . . . . . . . 75 13.4 trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . 75 14 contact information . . . . . . . . . . . . . . . . . . . . 75 15 contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76


▲Up To Search▲   

 
Price & Availability of P89CV51RD2FA512

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X